Download MetaTrader 5

Integer file write and read.

To add comments, please log in or register
persy5
18
persy5  
int file_handleb=FileOpen("buy",FILE_READ|FILE_WRITE|FILE_BIN|FILE_COMMON);


FileWriteInteger(file_handleb,1,INT_VALUE);

int a = FileReadInteger(file_handleb,INT_VALUE);
Comment(a);
Why the output of FileReadInteger is zero? How to fix it?
Alain Verleyen
Moderator
31182
Alain Verleyen  
persy5:
Why the output of FileReadInteger is zero? How to fix it?
Because you read at the end of the file. Use FileTell and FileSeek.
Documentation on MQL5: File Functions / FileTell
Documentation on MQL5: File Functions / FileTell
  • www.mql5.com
File Functions / FileTell - Documentation on MQL5
persy5
18
persy5  
I add this line
FileSeek(file_handle,0,SEEK_SET);
and it works. Thanks  a lot!
To add comments, please log in or register