Close_Output
See Also: File I/O Commands, Append_Output, Channel command component, Close_Input, Despool, Direct_Output, Flush_Output, Save, Sequential File I/O
Purpose
To close a sequential output file.
Syntax
Close_Output [Channel {channel-no}]
If {channel-no} is not specified, channel 1 will be assumed.
What It Does
Close_Output closes sequential files opened for output by the Append_Output and Direct_Output commands.
The Flush_Output command immediately forces a write of this cached data. This can be useful when writing to a log file while troubleshooting application crashes. Note that doing a flush is not necessary when closing the output, as the Close_Output command itself already does this.
Example
// Open and close the default I/O channel
Direct_Output "hello.txt"
Writeln "hello"
Close_Output
// Open and close I/O channel 3
Direct_Output Channel 3 "HelloAgain.txt"
Writeln Channel 3 "hello again"
Close_Output Channel 3
Notes
-
A sequential file is closed whenever another file is opened on the same sequential file channel.
-
A sequential file is closed when Abort is executed, when Runprogram (without the Wait option) is executed, or when Chain is executed without the Seq_Export option.
-
By closing the sequential output file, DataFlex requests the operating system to write the file to disk. The actual time the data is written depends on how Windows buffers its disk writes; however, it can be generally assumed that once the
Close_Outputis issued, the data will be safely written to disk.