If the MFS requires access to the current file, it should generally not generate an BASIC+ command to access the file. When an MFS uses BASIC+ commands to access a current file, those BASIC+ commands result in calls back to the same MFS.

In some instances, this can result in an infinite loop as the MFS processes these MFS-generated I/O calls. A good example is an MFS that spawns modified versions of the current call. For instance, a programmer might write an MFS that monitors record deletions in a programs file. When a delete is detected, the MFS spawns additional deletes to clean up the object code ($ records). If the MFS were to use BASIC+ commands, each subsequent DELETE would call the same MFS, which would spawn additional DELETE commands, etc.

Instead of using BASIC+ commands, the MFS can generate direct calls to the next MFS or the BFS. The following code fragment illustrates how an MFS might execute read-before-write logic using direct calls to the next filing system.  Note that the MFS must preserve any values that might be changed by the direct call (such as the value of the RECORD argument).

WRITE.RECORD:
* read-before-write logic here
READ.RECORD = 1
OLD.RECORD = ''
NEXTFS = BFS<1,1,2>
CALL @NEXTFS(READ.RECORD, FS, HANDLE,NAME, FMC, OLD.RECORD, STATUS)
IF STATUS THEN
  IF OLD.RECORD NE RECORD THEN
    CALL MSG(@window, "Record ":NAME:" has changed.")
  END ELSE
    CALL MSG(@window, "Record ":NAME:" has not changed.")
  END
END ELSE
  CALL MSG(@window, "Record ":NAME:" is a new record.")
END
* continue normal processing
GOSUB NEXT.MFS
RETURN
  • No labels