file_text_close

Once you have finished working with a given file (whether reading from it or writing to it), you must close the file again, or else you risk losing the information contained within. This also prevents memory leaks and makes sure that you never go over the file limit by having more than 32 files open.

The function will return true if the operation was a success, however if there was a failure in closing the file or when the file was first opened, this will return false.

 

Syntax:

file_text_close(fileid);

ArgumentTypeDescription
fileidText File IDThe id of the file to close.

 

Returns:

Boolean

 

Example:

var file = file_text_open_write(working_directory + "Game_Data.txt");
while (!file_text_eof(file))
{
    file_text_readln(file);
}
file_text_write_string(file, level_data);
file_text_close(file);

The above code opens a file for writing then loops through the lines of text already written to the file until it reaches the end. At this point it writes a string and then closes the file again.