Write in file
What did not work if your file is created ?
After I ran the EA the file is empty. No data is written. If I try to print out in the console everything is ok. P.S. MT5 is running on a virtual machine(VBOX) with winXP.
You don't have to use these flags :
filehandle=FileOpen("1.csv",FILE_WRITE|FILE_READ|FILE_CSV|FILE_ACCESS_DATE|FILE_IS_WRITABLE|FILE_IS_READABLE);
and check the return value of FileWrite().
You don't have to use these flags :
and check the return value of FileWrite().
I removed the flags and the return value of FileWrite() function is 64. As I read in the manual this is the number of bytes written and the file is still empty. But what am I concerned is when I change the name of the file to a non existing one the "filehandle" variable is still 1 and the return value of fileWrite() is still 64.
If the file doesn't exist it's created, please read the documentation carefully.
Anyway, I tried your code and it works. Attached the file created.
If the file doesn't exist it's created, please read the documentation carefully.
Anyway, I tried your code and it works. Attached the file created.
Hello,
I made a simple EA to write something in a file just for the sake of example but it didn't work.
void OnTick()
{
int filehandle;
filehandle=FileOpen("1.csv",FILE_WRITE|FILE_READ|FILE_CSV|FILE_ACCESS_DATE|FILE_IS_WRITABLE|FILE_IS_READABLE);
if(filehandle!=INVALID_HANDLE)
{
ResetLastError();
FileWrite(filehandle,TimeCurrent()," - ",Symbol());
Print ("err ",GetLastError()); ResetLastError();
FileClose(filehandle);
Print("FileOpen OK");
}
}
I got no errors and the "FileOpen Ok" message is written. My csv - "1.csv" is in MetaTrader 5\MQL5\Files
Also I noted that if I change the name of csv in my code from "1.csv" to "blabla.csv" I also got no errors. It's very weird and I can't figure out what I'm missing.
Can you help me with some advices?