Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following code fragment illustrates how the OPEN.FILE logic might look in an MFS that is tracking the OpenInsight file handle:

 

Code Block
OPEN.FILE:
FS = DELETE(BFS,1,1,1)
NEXTFS = FS<1,1,1>
CALL @NEXTFS(CODE, FS, HANDLE, NAME, FMC,RECORD,STATUS)
* add filename onto front of file handle,
* delimit with special character
RECORD = NAME:@TM:RECORD
RETURN

...

The following example code fragment illustrates a method to establish the arrays. In this example, the file name is stored as passed to the MFS, in the format filename*application.

 

Code Block
COMMON /FILENAME/ FILES.ARRAY,HANDLES.ARRAY
(other processing here)
OPEN.FILE:
* call BFS in order to get file handle
FS = DELETE(BFS,1,1,1)
NEXTFS = FS<1,1,1>
CALL @NEXTFS(CODE, FS, HANDLE, NAME, FMC,RECORD, STATUS)
* load handle and file name into labelled
common
IF STATUS THEN
  LOCATE NAME IN FILES.ARRAY USING @FM SETTING POS THEN
    HANDLES.ARRAY<POS> = RECORD
  END ELSE
    FILES.ARRAY<-1> = NAME
    HANDLES.ARRAY<-1> = RECORD
  END
END
RETURN

...

 

Once the arrays have been established, the MFS can extract the file name at any time that it has the file handle available.  The following code fragment illustrates a method by which the READ.RECORD logic might extract the file name: 

Code Block
READ.RECORD:
* search handle array to get position
LOCATE HANDLE IN HANDLES.ARRAY USING @FM SETTING POS THEN
  * extract corresponding file name
  FILE.NAME = FILES.ARRAY<POS>
END
FS = DELETE(BFS,1,1,1)
NEXTFS = FS<1,1,1>
CALL @NEXTFS(CODE, FS, HANDLE, NAME,FMC, RECORD, STATUS)
RETURN