GreatSamps:
[...]
this has me completely stumped, any ideas?
Pete
Isn't is just that, in read_arrays(), you're opening the files with FILE_WRITE rather than FILE_READ? Reading and writing multi-dimensional arrays using FileReadArray() and FileWriteArray() does work.
jjc:
Isn't is just that, in read_arrays(), you're opening the files with FILE_WRITE rather than FILE_READ? Reading and writing multi-dimensional arrays using FileReadArray() and FileWriteArray() does work.
LOL thankyou ... i had not spotted that. working fine now. sometimes you just need a second set of eyes!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
im having problems reading information out of a .dat file that an array has been saved into. i have two two dimensional Arrays,
int GridTracker[100][15];
int GridStatus[10][10];
i have a funtion that is writing that infomation to file
void write_arrays() // write data to a file to backup memory
{
int pgt,pgs;
pgt=FileOpen("panther-gt.dat", FILE_BIN|FILE_WRITE);
if(pgt>0)
{
Print("wrirte ", FileWriteArray(pgt, GridTracker, 0, 1500));
FileClose(pgt);
}
pgs=FileOpen("panther-gs.dat", FILE_BIN|FILE_WRITE);
if(pgs>0)
{
Print("write ", FileWriteArray(pgs, GridStatus, 0, 100));
FileClose(pgs);
}
}
when this function runs, the result of the FileWriteArray is 1500 and 100. i.e. the size of the arrays.
i have another function which then reads from the file
void read_arrays() // read data to a file to backup memory
{
int pgt,pgs;
pgt=FileOpen("panther-gt.dat", FILE_BIN|FILE_WRITE);
if(pgt>0)
{
Print(FileReadArray(pgt, GridTracker, 0, 1500));
FileClose(pgt);
Print(GetLastError());
}
pgs=FileOpen("panther-gs.dat", FILE_BIN|FILE_WRITE);
if(pgs>0)
{
Print(FileReadArray(pgs, GridStatus, 0, 100));
FileClose(pgs);
}
}
the result from both operations is zero, i.e. no items read. the result from GetLastError() is also zero, and the result from the FileOpen operations is 1 i.e successfull.
this has me completely stumped, any ideas?
Pete