Problem with FileReadString - should be simple to fix

 

Hello

I have a file which I wrote with Notepad which contains:

1406718000

1406719800

so should have Win line endings.


This code:

void readInTradeEvents() {
    i = 0;
    int fh=FileOpen("eventdates.txt",FILE_READ);
    if(fh != INVALID_HANDLE) {
        ArrayResize(dates, 0);      // empty and refill
        ArrayResize(dates, ArraySize(dates)+1);
        FileSeek(fh,0,SEEK_SET);
        while(!FileIsEnding(fh)) {
            dates[i] = StringToInteger(FileReadString(fh,10));
            PrintFormat(dates[i]);
            i += 1;
        }
        FileClose(fh);
        Print("Read ",ArraySize(dates)," dates into dates array");
        SendNotification(StringConcatenate("EA ",tradeNote," [",Symbol(),"]: Reread eventdates.txt"));
    }
    else Print("Read of event dates file failed. Error: ",GetLastError());    
}


Parses the file and the EA outputs only the first entry (which is the second line in the log once the second line is output too):

0

1406718000


What am I doing wrong?  This was working not so long ago.  I've tried a number of different combinations and none work.  The EA only reports that it has read in one entry only.

 
You don't resize the array dates in your while loop
 
int fh=FileOpen("eventdates.txt",FILE_READ|file_write);
 
GumRai:
You don't resize the array dates in your while loop

GumRai, exactrly right - thanks.
Reason: