Download MetaTrader 5
To add comments, please log in or register
Do you often publish source codes? Find out how to do that correctly!
brettosm8
241
brettosm8 2014.07.28 13:02 

Hi there,

I run an EA in ST ok.  It reads dates and times from a file in tester\files.

If I run the EA in debug mode, FileOpen() returns -1.  It appears when using debug mode the EA looks for the file in MQL4\files because trying to open that file in debug mode displays a blank screen with a message about how the file is in use by another program.

Why does FileOpen() return -1 in debug mode but not encounter an error for this when run in ST?

I'm using MetaEditor v5.00 build 966.

Thanks.

Drazen Penic
2406
Drazen Penic 2014.07.28 14:52  

Use this code to find out error code:

   int filehandle=FileOpen(filename,FILE_WRITE|FILE_CSV);
   if(filehandle<0)
     {
      Print("Failed to open the file by the absolute path ");
      Print("Error code ",GetLastError());
     }

 

 Above code is copied from the help for the FileOpen() function.

Hongliang Liu
1196
Hongliang Liu 2014.07.29 06:37  
brad:

... with a message about how the file is in use by another program....

remember to close file every time after used.

FileClose(handle);

/
To add comments, please log in or register