FILEIO Example


Example:

 

FILE

FILE

 

HOW

FORM

1

METHOD

FORM

1

FIELD

DIM

10(3)

.

 

 

  

FILEIO

FILE,HOW,METHOD;FIELD(1),FIELD(2),FIELD(3)

 

If METHOD contained a value of one, this would be treated as a READ instruction. Whether this was a sequential or random read would be determined by the contents of HOW. If HOW contained a value less than zero, it would be treated as a sequential read. If HOW was zero or greater, it would be treated as a random read.

 

If METHOD contained a value of two, this would be treated as a WRITE instruction. Whether this was a sequential or random WRITE would be determined by the contents of HOW. If HOW contained a value less than zero, it would be treated as a sequential write. If HOW was zero or greater, it would be treated as a random write.

 

Using this example, it would be possible to use one I/O instruction for both reads and writes to the logical file named FILE. Besides reducing code, this instruction helps reduce programmer coding mistakes in variable lists that are specified more than once.

 



PL/B Language Reference FILE Examples FILELIST Example