October 31, 2025, 11:40:46 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Forcing a buffer flush when writing a file?

Started by Hootie, October 24, 2008, 06:09:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hootie

Is there any way in Ebasic to do a fflush()?  I'm writing an error logging module and I want to keep the log file buffer flushed in case of program crash so all the messages will be in the log up to the crash.

Ionic Wind Support Team

The simplest way is just to close the file after each write.

OpenFile(LogFile, LogFileName, "A")
...write
CloseFile(LogFile)

Which is a method I use on a larger server project.

Of course if you just want to use the Windows API both the FILE and BFILE variables are a handle to the open file created with CreateFile:

Declare import, FlushFileBuffers(uint hFile),int
...
FlushFileBuffers(LogFile)

Ionic Wind Support Team

Hootie