MQL4 - automated forex trading   /  

Documentation

MQL4 Reference  File functions  FileWriteInteger

 
int FileWriteInteger( int handle, int value, int size=LONG_VALUE)
The function writes the integer value to a binary file. If the size is SHORT_VALUE, the value will be written as a 2-byte integer (the short type), if the size is CHAR_VALUE, the value will be written as a 1-byte integer (the char type), and if the size is LONG_VALUE, the value will be written as a 4-byte integer (the long int type).
Returns the actually written bytes count or a negative value if an error occurs.
To get the detailed error information, one has to call the GetLastError() function.
Parameters:
handle   -   File handle returned by the FileOpen() function.
value   -   Value to be written.
size   -   Optional format flag. It can be any of the following values:
CHAR_VALUE (1 byte),
SHORT_VALUE (2 bytes),
LONG_VALUE (4 bytes, default).
Sample:
  int handle;
  int value=10;
  handle=FileOpen("filename.dat", FILE_BIN|FILE_WRITE);
  if(handle<1)
    {
     Print("can't open file error-",GetLastError());
     return(0);
    }
  FileWriteInteger(handle, value, SHORT_VALUE);
  //...
  FileClose(handle);