FileIsLineEnding doesn't reset the EOL flag?

 

It appears that FileIsLineEnding does not reset the EOL flag when called. This makes it impossible to use it to iterate over lines of text in the following fashion:

1   while (!FileIsEnding(fh)) {
2      while (!FileIsLineEnding(fh)) {
3         words[i++] = FileReadString(fh);
4      }
5   }

The first line is read (and broken down into words), however the second line can not be read, because FileIsLineEnding on line 2 keeps returning True.

What is the work around this?

MetaTrader Version 4.00 Build 1090

 
xsgex: FileIsLineEnding on line 2 keeps returning True. What is the work around this?
  1. The file is not ending, the line is not ending. You start reading words.
  2. After reading the last word on a line you get line is ending, file is still not.
  3. Until you read again, nothing changes. You have an infinite loop.
while (!FileIsEnding(fh)) {
   while (!FileIsLineEnding(fh)) {
      words[i++] = FileReadString(fh);
}  }
Always read until EOF.
while (!FileIsEnding(fh)){
   do{
      words[i++] = FileReadString(fh);
   while (!FileIsLineEnding(fh));
   // Do something at EOL
}
//EOF
 If you don't need to do something at end of line, stop checking for it. 
while (!FileIsEnding(fh)){
   words[i++] = FileReadString(fh);
}
//EOF
 
whroeder1:
  1. The file is not ending, the line is not ending. You start reading words.
  2. After reading the last word on a line you get line is ending, file is still not.
  3. Until you read again, nothing changes. You have an infinite loop.
Always read until EOF.
 If you don't need to do something at end of line, stop checking for it. 



Thanks! The do-while construct is what I needed, and I'm embarrassed that I didn't think of it sooner.
Reason: