Skip to content

SeqEOF Global Variable

See Also: Sequential File I/O, Close Input, Close Output, Direct Input, Direct Output, Read, Read Block, Readln

Purpose

To indicate that the end of a sequential input file has been reached.

Type

Boolean

What It Does

When read_block, read, or readln encounters an end of file (EOF) character, it sets SeqEOF to true. If you use the direct_input command to open a file that is not found, SeqEOF is set to true. If the filename in the direct_input command is "", SeqEOF will be set to false.

SeqEOF is commonly used to control the execution of loops that read data from sequential files.

Open Trees
Direct_Input "trees.txt"
If (Not(SeqEOF)) Begin
    Repeat
        Clear Trees
        Readln Trees.Species Trees.Height
        Save Trees
    Until (SeqEOF)
End

In this example, the input file TREES.TXT is opened and, if it is found, data is read from it into new records of the database file Trees. When the end of the file is reached, SeqEOF is set to true, and the repeat ... until loop terminates. If TREES.TXT is not found in the folder, SeqEOF will be set to true by the direct_input command, and the repeat ... until loop will never execute.

Notes

  • Never rely on the value of the SeqEOF indicator other than on the line immediately following the line of code that sets it. Many different commands and messages alter the value of SeqEOF and other global indicators.

  • Different operating systems indicate EOF in different ways. DataFlex interprets EOF in whatever way it is indicated in the host operating system and sets SeqEOF so that the condition may be dealt with using a single version of the program whose commands are not operating system-dependent.

  • The following commands set SeqEOF to false unconditionally: close_input, close_output, and direct_output.