file_text_open_from_string

这个函数将从一个字符串创建一个文本文件,并打开它进行读取,返回文件“句柄”,这个文件“句柄”应该用于所有进一步的文件函数调用中,以便从这个文件中读取。请注意,这个文件是临时的, 只读 ,因此,它将在关闭时从内存中删除。

In the case of an error, the function will return -1. However, in some cases where the file could not be loaded (like an invalid filename being passed), the function may still return a file ID, in which case the return value of the file closing function will be false.

NOTE You can only have a maximum of 32 files open at any one time. You should also always close files when finished as this writes the information and frees the memory associated with the file.

WARNING This may not work as you expect due to GameMaker being sandboxed! Please see the section on The File System for more information.

 

语法:

file_text_open_from_string(string);

参数类型描述
stringString要从中创建文件的字符串。

 

返回:

Text File ID or -1

 

例子:

file = file_text_open_from_string(reset_str);

上面的代码获取存储在变量“reset_str”中的字符串,并使用它创建一个只读文本文件。然后,该文件的“句柄”被存储在变量“ file”中,以供所有进一步的文件函数使用。