You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

An MFS is called once for each file operation (note that one BASIC+ call or routine called from the System Monitor may translate into several MFS calls). Each file operation typically requires separate logic within the MFS. For example, an MFS will usually execute different logic for a read and a write operation.

The first argument passed to the MFS (the CODE argument) contains an integer value that indicates the operation that has been requested. For example, if the operation is "read a record," CODE will contain the value 1. If the operation is "delete a file," CODE will contain the value 15, and so forth.

Note: standard constant names for the CODE argument are provided in the $INSERT record FILE.SYSTEM.ONGOSUB. These standard names are used within this chapter for clarity.

The MFS must determine what operation is being performed, and branch or "dispatch" to the appropriate logic within the MFS.

Two methods are commonly used when coding an MFS dispatch routine.  They are:

Using ON...GOSUB in an MFS Dispatch Routine

The first method uses the BASIC+ ON ... GOSUB statement to branch to a local subroutine for each file operation. The CODE argument provides the index value for the ON...GOSUB statement. The GOSUB portion is followed by a list of 28 statement labels. Each statement label identifies the logic within the body of the MFS program for a particular file operation.

A typical statement begins like this:

ON CODE GOSUB READ.RECORD, READO.RECORD, WRITE.RECORD, DELETE.RECORD, LOCK.RECORD ...

For example, if a record lock operation is being executed, the value of CODE will be 5. The ON ... GOSUB statement will branch to the fifth statement label, in this case LOCK.RECORD.

Very frequently, the MFS is concerned with only a small number of file operations, such as READ.RECORD and WRITE.RECORD. In this case, the logic for most remaining operations can be lumped under a single label in the MFS. The MFS might "stack" statement labels that have code in common, as in this example:

 

READ.RECORD
   (record read logic here)
  RETURN
CREATE.FILE:
RENAME.FILE:
DELETE.FILE:
("do nothing" logic here)
RETURN

 

 

  • No labels