Repository navigation
Fileflush
Home › Operating System Functions › FileFlush
Writes buffered output for one or all open files to the system, or on to disk.
Declare Function FileFlush ( ByVal filenum As Long = -1, ByVal systembuffers As Long = 0 ) As Longfilenumsystembuffers
FileFlush writes application buffered output to the underlying stream, and if systembuffers is non-zero, to the underlying physical device as well.
In the form FileFlush(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, and line buffered for append and output files. The FileFlush function overrides the normal buffering of the application and immediately writes buffered output to the system. The system may have it's own buffers as 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 system buffers are flushed to physical device.
Returns zero (0) for success or an error code if file buffers could not be flushed.
#include "file.bi"
result = FileFlush()
result = FileFlush( filenum )
result = FileFlush( filenum, systembuffers )- New to FreeBASIC.
#include "file.bi"
Dim As Long f1, f2
Dim As String s
Print "File length", "File string"
f1 = FreeFile
Open "fileflushtest.txt" For Output As #f1
Print #f1, "successful file flush"
f2 = FreeFile
Open "fileflushtest.txt" 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
Print FileLen("fileflushtest.txt"), "'" & s & "'" '' the string is now physically written to the file
Close #f2
Close #f1
SleepOutput (Windows):
File length File string
0 ''
23 'successful file flush'
Category: Operating System Functions
Kind: function
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing