I am trying to create a textfile with MQL4. No sucess. It just doesn't work. A very simple script:
void OnStart() {
string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
string filename=terminal_data_path+"\\MQL4\\Files\\"+"teste2.txt";
int filehandle = FileOpen(filename,FILE_WRITE|FILE_TXT);
FileWriteString(filehandle,"teste");
FileClose(filehandle);
}
This fires error 5002. OK, the file does not exist. I thinked that the script will create the file.
So, I decided to create an empity "teste2.txt" with notepad in the folder. The same error.
Can someone help me?
Thanks
The file is written by default in .../MQL4/Files, so just writting that code works (it creates a file named teste2.txt with teste written in it in .../MQL4/Files) :
void OnStart()
{
int filehandle = FileOpen("teste2.txt",FILE_WRITE|FILE_TXT);
FileWriteString(filehandle,"teste");
FileClose(filehandle);
}
Of course you will need to check the return of the FileX functions (FileOpen, fileWrite, FileClose, etc)