The 'FileOpen' function opens the specified file.
DWORD FileOpen(string file_name, string method);
Note : Only if a file is opened, you can read data from the file or write data to the file. In other words, only if you use the 'FileOpen' function, you can use the 'FlieRead' function or the 'FileWrite' function to read data from the file or write data to the file. Also, after you finish your use of the file, you must always close the file. In other words, after you use the 'FileOpen' function, you must always use the 'FileClose' function.
Parameters
string file_name : file name that you want to open
string method : option
"r" - The file is opened read-only. If the file don't exist, 'Return Value' is '0'.
"w" - The file is opened write-only. If the file doesn't exist, the file is made. If the file exists, previous data is deleted and new data is written.
"a" - The file is opened write-only. If the file doesn't exist, the file is made. If the file exists, new data is written to the end of the file.
Return Value
condition of the file (0 = The file is not opened, 1 or higher = The file is opened)
When 'Return Value' is '0', the probable reason is as follows : The file doesn't exist. / Another program is using the file. / You are using a character that is not allowed
Example 1
handle = @FileOpen("C:\\EX.TXT", "a");
if(handle != 0)
{
@FileWrite(handle, "example data", 12);
@FileClose(handle);
}
Description : The first line is to open the file named 'EX.TXT' in C drive. If the file is opened, 'example data' is written to the file. Afterward, the file is closed by the '@FileClose(handle);'.
Example 2
handle = @FileOpen("C:\\EX.TXT", "r");
if(handle != 0)
{
@FileRead(handle, buf, 12);
@FileClose(handle);
}
Description : The first line is to open the file named 'EX.TXT' in C drive. If the file is opened, twelve data of the file is stored in the variable named 'buf'. Afterward, the file is closed by the '@FileClose(handle);'.