MQL4 - automated forex trading   /  

Documentation

MQL4 Reference  File functions  FileOpen

 
int FileOpen( string filename, int mode, int delimiter=';')
Opens file for input and/or output. Returns a file handle for the opened file or -1 (if the function fails). To get the detailed error information, call GetLastError() function.
Notes: Files can only be opened in the terminal_directory\experts\files folder (terminal_directory\tester\files if for expert testing) or in its subfolders.
FILE_BIN and FILE_CSV modes cannot be used simultaneously.
If FILE_WRITE does not combine with FILE_READ, a zero-length file will be opened. If even the file containd some data, they will be deleted. If there is a need to add data to an existing file, it must be opened using combination of FILE_READ | FILE_WRITE.
If FILE_READ does not combine with FILE_WRITE, the file will be opened only if it already exists. If the file does not exist, it can be created using the FILE_WRITE mode.
No more than 32 files can be opened within an executable module simultaneously. Handles of files opened in the same module cannot be passed to other modules (libraries).
Parameters:
filename   -   Filename.
mode   -   Opening mode. It can be one or combination of values: FILE_BIN, FILE_CSV, FILE_READ, FILE_WRITE.
delimiter   -   Delimiter character for csv files. By default, the ';' symbol applies.
Sample:
  int handle;
  handle=FileOpen("my_data.csv",FILE_CSV|FILE_READ,';');
  if(handle<1)
    {
     Print("File my_data.dat not found, the last error is ", GetLastError());
     return(false);
    }