MQL4 Reference
File functions
FileWriteArray
| int FileWriteArray( |
int handle, object array[], int start, int count) |
The function writes the array to a binary file. Arrays of int, bool, datetime and color types will be written elementwise, as 4-bytes integers.
Arrays of double type will be written elementwise, as 8-bytes floating point numbers.
Arrays of string type will be written by strings, the line end character "\r\n" to be added at each string automatically.
Returns the number of written elements 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. |
| array[] |
- |
Array to write. |
| start |
- |
Starting index in the array (the first written element number). |
| count |
- |
Count of elements to be written. |
Sample:
int handle;
double BarOpenValues[10];
// copy first ten bars to the array
for(int i=0;i<10; i++)
BarOpenValues[i]=Open[i];
// writing array to the file
handle=FileOpen("mydata.dat", FILE_BIN|FILE_WRITE);
if(handle>0)
{
FileWriteArray(handle, BarOpenValues, 3, 7); // writing last 7 elements
FileClose(handle);
}
|
|
|