FLUSH |
![]() ![]() ![]() |
The FLUSH statement flushes the internal buffers for a directory file record previously opened for sequential access.
Format
FLUSH file.var {THEN statement(s)} {ELSE statement(s)}
where
At least one of the THEN and ELSE clauses must be present. The THEN clause is executed if the operation is successful. The ELSE clause is executed if the FLUSH operation fails.
The sequential file buffers are automatically flushed periodically during file usage and on closing the file. The FLUSH statement allows the programmer to ensure that data is flushed to disk at a given point in the program
The WRITESEQF statement is the equivalent of a WRITESEQ followed by a FLUSH. Flushing the buffers after every write may result in poor performance.
Example
LOOP LINE = REMOVE(LIST, CODE) WRITESEQ LINE TO SEQ.F ELSE ABORT "Write error" WHILE CODE REPEAT FLUSH SEQ.F ELSE ABORT "Flush error"
This program fragment writes a series of text lines extracted from LIST to a sequential file and then flushes the buffers to verify that the data has been written to disk.
See also: CLOSESEQ, NOBUF, READBLK, READCSV, READSEQ, SEEK, WEOFSEQ, WRITEBLK, WRITECSV, WRITESEQ, WRITESEQF |