Skip to content

257B OpenFileInfo

In progress   MON 257B (175 decimal) · Mnemonic FOPEN, POPFN · Group: File System Operations (manual section 2.9)

Available from: All programs (manual compatibility box)

Emulation source: src/handlers/mon_257B_OpenFileInfo.c

Description

Gets information about an open file. You specify the file name. The monitor call returns the file number and the access type. The logical device number of peripheral equipment is returned for peripheral files. Accepts COSMOS RFA.

Parameters

Name Type Direction Description
FileName STRING In File name.
FileType STRING In File type.
FileNo INTEGER2 Out File number. If error return, this parameter contains the Logical Device Number (LDN) of peripheral device (only for peripheral files).
AccessCode INTEGER2 Out Access code. 0 means read. 1 means write. 2 means read and write.
DevNo INTEGER2 Out Logical device number of peripheral device. This is only relevant for peripheral files.
ErrCode INTEGER2 Out Standard Error Code. See appendix A.

Direction: In = the program supplies the value, Out = the call returns it, In/Out = both.

See also

OpenFile

Compatibility

Machines Users Programs
ND-100 and ND-500 All users All programs

The manual's compatibility box for this call, word for word.

Yes/no fields from the YAML extraction (not in the manual's words):

ND-100 ND-500 User programs RT programs System programs
Yes Yes Yes Yes No

Examples

From the manual (OCR text, not corrected).

BYTES : FileName(0:63), FileType(0:3)
INTEGER : FileNo, AccessCode, DevNo
...
ON ROUTINEERROR DO
IF ErrCode > 0 THEN ...
ENDON
Monitor_Call('OpenFileInfo', FileName, FileType, FileNo,&
AccessCode, DevNo)
CHARACTER FileName*64, FileType*4
INTEGER FileNo, AccessCode, DevNo
...
Monitor_Call('OpenFileInfo', FileName(1:64), FileType(1:4), FileNo,
                                 AccessCode, DevNo)
IF (ErrCode .NE. 0) THEN ...
FileName : PACKED ARRAY [0..63] OF CHAR;
FileType : PACKED ARRAY [0..3] OF CHAR;
FileNo, AccessCode, DevNo : INTEGER2;
...
GetOpenFileInfo(FileName, FileType, FileNo, AccessCode, DevNo);
IF ErrCode <> 0 THEN ...
01 FileName PIC X(64).
01 FileType PIC X(4).
01 FileNo COMP.
01 AccessCode COMP.
01 DevNo COMP.
01 ErrCode COMP.
...
MONITOR-CALL "OpenFileInfo" USING FileName, FileType, FileNo,
                                 AccessCode, DevNo.
CALL "CbError" USING ErrCode.
IF ErrCode NOT = 0 GO ...
FileName    : STRINGDATA  'EXAMPLE'     %Get open-file info
FileType    : STRINGDATA  'SYMB'        % of EXAMPLE:SYMB.
FileNo      : W BLOCK  1                %ND-500 open file number.
DevNo       : W BLOCK  1                %Peripheral device number.
OpenCode    : W BLOCK  1                %Access code.
S3No        : W BLOCK  1                %Optional SINTRAN III open file number as 6th param.
ErrCode     : W BLOCK  1
OpenFileInfo: EQU 37B9 + 257B
...
CALLG OpenFileInfo, 5, FileName, FileType, FileNo, OpenCode, DevNo
IF K GO ERROR
...
ERROR : W1 =: ErrCode                %ErrorCode in W1 register.
LDX   (FILE       %Address of string containing file name.
LDA   (TYPE       %Address of string containing default file type.
MON   257         %Monitor call OpenFileInfo.
JMP   ERROR       %Error return from monitor call.
STT   FILNO       %Normal return, store file number returned.
STA   ACODE       %Store access code.
COPY  SD DA
STA   DEVNO       %Store peripheral dev. number, if peripheral file.
...
ERROR, ...        %Handle error, register A: error number,
...               % register D: peripheral file number.
FILE,  'EXAMPLE'  %Obtain file number for EXAMPLE:SYMB.
TYPE,  'SYMB'
FILNO, 0
ACODE, ...
DEVNO, ...

ndmonlib implementation

In progress Registered MON_STATUS_IN_PROGRESS: partly implemented. The dispatcher calls the handler.

Handler mon_257B_OpenFileInfo
Code lines 83 (non-blank, non-comment lines in the file)

Notes from the handler source

src/handlers/mon_257B_OpenFileInfo.c line 34

Read an ND-500 STRING argument that is a [len:4][ptr:4] descriptor. Copies
up to max-1 bytes of the target text into out (NUL-terminated), stripping a
trailing 0x27 apostrophe if present. Returns the logical length.

src/handlers/mon_257B_OpenFileInfo.c line 51

Compare a table object_name (may be 0x27- or NUL-terminated, fixed field)
against a C string, case-insensitively.

src/handlers/mon_257B_OpenFileInfo.c line 95

Not open. Return the SINTRAN "no such open file" style error via K clear
so the linker's if-not-k branch opens the file itself (fallback path).

src/handlers/mon_257B_OpenFileInfo.c line 103

Map access_mode (SINTRAN open code) to FOPEN AccessCode {0 read,1 write,
2 read+write}.

Source

SINTRAN III Monitor Calls (ND-860228.2 EN), page 370.