Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Start earning money!
Don De Rota
69
Don De Rota 2015.01.31 23:18 

My EA always compiled without any warnings, but recently decided to compile again and have been getting these warnings.


For the life of me, I cannot work out why as I'm storing the return value of the File* functions in the correct variable type and only

using those variables as int values in the rest of my code

void StoreOrderOpenPrice(string argFile, int argTicket, string argPair, int argType, double argPrice)
{
   int handle = FileOpen(argFile, FILE_READ|FILE_WRITE|FILE_CSV, ',');

   if(FileSize(handle) > 0)
      FileSeek(handle, 0, SEEK_END);

   if(handle < 0)
      Print(GetErrorDescription(GetLastError()));

   int recorded = FileWrite(handle, argTicket, argPair, argType, argPrice);

   if(recorded < 0)
      Print(GetErrorDescription(GetLastError()));

   FileClose(handle);
}
Keith Watford
Moderator
7976
Keith Watford 2015.01.31 23:52  

FileWrite returns a uint, not an int.

Also note that it returns zero in the case of an error, so your error reporting will not work correctly 

Keith Watford
Moderator
7976
Keith Watford 2015.01.31 23:54  
Double click on the warnings and the cursor will show you exactly where they are in the code.
Don De Rota
69
Don De Rota 2015.02.01 00:47  

Thx GumRaj all fixed,   replaced  "  < 0  "  with   " == 0" for the error checking.


cheers

/
To add comments, please log in or register