View Single Post
  #93 (permalink)  
Old 05-15-2008, 04:51 PM
ingvar_e ingvar_e is offline
Junior Member
 
Join Date: Dec 2007
Location: Outside Stockholm
Posts: 20
ingvar_e is on a distinguished road
Well, perserverance rules!

After several hours I found out this:

The file handler refuses to open a file I have created with another program. Open returns -1. If I use the file that was created by the demo (mt4.log) and copies my content into it open works. Cant figure out why. Strange

I made my "records" fixed length and read the length of the "record" plus 2 to accomodate for "CRLF" at the end of each record. I got the length of the file, divided by the record length and looped to get all my records into an array:

Here is the code:

int init()
{

string inArr[500];
int file;
int filesize;
int records;
int i;

file = gFileOpen("c:\mt4.log",READ);
// Print(file);
filesize = gFileSize(file);
// Print(filesize);
records = filesize/25;
// Print(records);

for(i=1;i<=records;i++)
{
inArr[i-1] = gFileRead(file,25);
}

gFileClose(file);

Print(inArr[filesize-1]); //Check the last one

return(0);
}
Reply With Quote