Introduction MTB Statements File System Compiler Applications Reference Guide Index

Language Structure Data Division I/O Format Division Procedure Division Mnemonics

FILE (lun) FORWARD

Syntax: FILE (lun) FORWARD
Discussion: The FILE (lun) FORWARD statement sets the read pointer in the forward direction. Subsequent sequential reads will return records in ascending ASCII order of the keys.

The logical unit number (lun) parameter refers to a currently open keyed file. As the program performs sequential reads (i.e., reads without a specific key), the records will be returned in ascending ASCII order of the keys in the key tree.

Note: The FORWARD direction is the default for files when they are opened.

See FILE (lun) REVERSE.

History: Prior to Comet version 503.84, when a file direction command was issued (to change the direction of the file pointer), the file pointer was advanced one record. For example, if the pointer was moving in ascending ASCII order through the key tree and the FILE (lun) FORWARD statement was issued following a successful READ, the pointer would advance one more record. The same situation occurred if the pointer was moving in descending ASCII order through the key tree.

This problem was fixed in Comet version 503.84. Now whenever a "change of direction" command is issued, the file system first checks to see which direction the file pointer is moving. If the pointer is moving the same direction as the command, the command is ignored and the file pointer is not advanced. If the pointer is moving the opposite direction as the command, the file pointer is advanced one record in that direction, then the direction is changed to the opposite direction.

Example:
OPEN (1) "CUSTHIST",DIR="DSK"
FILE (1) FORWARD
This example opens a file named CUSTHIST as logical unit number 1, and specifies that sequential read operations proceed in ascending ASCII order. Because the read pointer direction is forward by default when as file is open, the second line in this example is redundant.