Go to: Synopsis. Return value. Related. MEL examples.


fflush int

fflush is NOT undoable, NOT queryable, and NOT editable.

This command is used after you have opened a file and have written to it but have not closed it yet. fwrite and fprint do not actually write directly onto your disk. They write into a software buffer. When the buffer is full it writes out to disk in one go. This means there are fewer I/O accesses so the program doesn't slow down. If you want to force the buffer to be written to disk then you use fflush. Note that this is normally done just before something risky that might cause a crash, so is usually only used during development. If you crash then you lose whatever is in the buffer.

Return value



fclose, feof, fgetline, fgetword, fopen, fprint, fread, frewind, fwrite, pclose, popen

MEL examples

// Write some data into a file
$exampleFileName = ( `internalVar -userTmpDir` + "example.tmp" );
$fileId=`fopen $exampleFileName "w+"`;
fprint $fileId "Hello there\n";

// Make sure the data is witten to the file
fflush $fileId;

// Rewind and read it back
frewind $fileId;
print( `fgetline $fileId` );
fclose $fileId;