Invalid Handle
Whats this line suppose to be doing?
if (!AnalHandle == FileOpen("AnalArray.dat", FILE_BIN|FILE_READ))
Whats this line suppose to be doing?
It is a test to see if the file already exists. If it does not exist then the code should then build the file. If it does exist it should then read the file and put it back into MyArray. Basically if the EA looses the connection the code should recognise the loss and rebuild the array from the file.
I do not understand what I am doing wrong here. I am getting Invalid Handle messages for writing the file as well as flushing and closing. See the code and the log. Also, why does it print the correct data only for the first loop. HELLLPPPP!!!!!
How can you write to a file that you have opened just with read access ?
if (!AnalHandle == FileOpen("AnalArray.dat", FILE_BIN|FILE_READ ) ) // <---- Binary file opened for reading . . . . . . for (i = 0; i < Row; i++) { for (j = 0; j < Column; j++) { FileWriteArray(AnalHandle, MyArray, i, Column); // <---- writing to file
Please read the documentation: FileOpen()
No It doesn't. Where do you assign AnalHandle to the FileHandle before using it in
FileWriteArray(AnalHandle, MyArray, i, Column);
????
No It doesn't. Where do you assign AnalHandle to the FileHandle before using it in
????
I guess here :)
int RestartDetect = 1, AnalHandle = 0, i = 0, j = 0, Row = 3, Column = 5;
Your code if (!AnalHandle == FileOpen("AnalArray.dat", FILE_BIN|FILE_READ))
AnalHandle is zero (first time, everytime) same as (This may or may not be true the first time will never be true thereafter) but after the statement, you have lost the handle, can't write and can't close if (1 == FileOpen("AnalArray.dat", FILE_BIN|FILE_READ))
Open the file, test the result, SAVE the handle for use AnalHandle == FileOpen("AnalArray.dat", FILE_BIN|FILE_READ); if (AnalHandle < 0) // file does not exist.
- If you try to open the file for reading you can't write to it.
I do not understand what I am doing wrong here. I am getting Invalid Handle messages for writing the file as well as flushing and closing. See the code and the log. Also, why does it print the correct data only for the first loop. HELLLPPPP!!!!!