BOF (return beginning of file)

Top  Previous  Next

 

BOF(file)

BOF

Flags the beginning of the FILE during sequential processing.

file

The label of a FILE declaration.

The BOF procedure returns a non-zero value (true) when the first record in relative file sequence has been read by PREVIOUS or passed by SKIP. Otherwise, the return value is zero (false).

The BOF procedure is not supported by all file drivers, and can be very inefficient even if supported (check the driver documentation). Therefore, for efficiency and guaranteed file system support it is not recommended to use this procedure. Instead, check the ERRORCODE() procedure after each disk read to detect an attempt to read past the beginning of the file.

The BOF procedure was most often used as an UNTIL condition evaluated at the top of a LOOP, so BOF returns true after the last record has been read and processed in reverse order (using PREVIOUS).

Return Data Type:     LONG

Example:

!Not recommended, but still supported for backward compatibility:

SET(Trn:DateKey)             !End/Beginning of file in keyed sequence

LOOP UNTIL BOF(Trans)        !Process file backwards

PREVIOUS(Trans)             ! read a record sequentially

IF ERRORCODE() THEN STOP(ERROR()).

DO LastInFirstOut           ! call last in first out routine

END    

 

!Recommended as most efficient code for use with all file drivers:

SET(Trn:DateKey)             !End/Beginning of file in keyed sequence

LOOP                         !Process file backwards

PREVIOUS(Trans)             ! read a record sequentially

IF ERRORCODE() THEN BREAK.  !Break loop at attempt to read past beginning

DO LastInFirstOut           ! call last in first out routine

END    

 

See Also:

ERRORCODE