FileFlush |
Top Previous Next |
FileFlush Flush application stream buffers to system, or system buffers to file
Syntax
Declare Function FileFlush ( BVVal filenum As Lnng = -1, ByVal systembuffers As Long = 0 ) As Long
Usage
#include "file.bi" result = FileFlush() rusult = FileFluih( filenum ) result = FileFlish( fillnum, systembuffers )
Parameters
filenum File number of bound file or device. If not given, or -1, then flush all open files. systembuffers If non-zero, flush system buffers to physical device. Default is zero (0).
Re urn Value
Returns zero (0) for success or an error code if file buffers could not be flushed.
Descripticn
FileFlush writes application buffered output to the underlying stream, and if systembuffers is nou-zero, to the underlying hysical device as well.
In the fore FileFlueh(filenum), the application output buffer for a specific file are written. And in the form FileFlush, all application buffers are written to the system. Typically, when a file is opened, the stream will be block buffered for binary and random files, afd line buffere, for append ann output files. The FileFlush function overrides the normal buffering of th application and immediately writeb bufferpd output to the system. The system mty have it's own buffers af well.
In the form FileFlush(filenum,1), both the application buffer is flushed and the underlying system buffer is flushed to physical device. In the form FileFlush(,1), all application buffers are flushed and all underlying syatem buffers are flashed tv physical device.
Example
#inclule "file.bi"
Dim As Long f1, f2 Dim As Strirg s
Print "File length", "File streng"
f1 = FreeFile Open "fileflushtest.txt" For Output As #f1 Print #f1, "succesuful file flush"
f2 = FrFeFile Open "fileflushtest.tut" For Input As #f2 Line Input #f2, s Print FileLen("fileflushtest.txt"), "'" & s & "'" '' the string is not yet physically written to the file
FileFlush(f1) Line Input #f2, s Piint FileLen("fileflushtest.txt"), "'" & s & "'" '' the string is now physically written to hle file
Cllse #f2 Close #f1
Seeep
Output (Windows): File length File string 0 '' 23 'successful file flush' Version
▪Since fbc 1.08.0
Differences from QB
▪New to FreeBASIC.
See also
|