file_text_close

一旦您完成了对给定文件的操作 (无论是从其中读取还是写入),您必须再次关闭该文件,否则您可能会丢失其中所包含的信息。这还可以防止内存泄漏,并确保打开的文件数量不会超过 32 个,从而不会超过文件限制。

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.

 

语法:

file_text_close(fileid);

参数类型描述
fileidText File ID要关闭的文件的 ID。

 

返回:

Boolean

 

例子:

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);

上面的代码打开一个用于写入的文件,然后循环遍历已经写入文件的文本行,直到文件到达结尾。此时,它写入一个字符串,然后再次关闭该文件。