FileReadNumber() bug?

 

Hi,


I just saw MT4 behaving very strange.

When parsing a CSV-file of integers without an empty line at the end of the file, it keeps looping with 99% CPU.


The file:

38974;293847
293874;39847
942387;94387

the file is read correctly till FileReadNumber() gets to the very last value (94387), there it simply does not wanna read the number and starts making loops.

The work-around I am using is to make use of FileReadString() (which does not cause this loop) and parse the string to an integer. This solution is needed anyways because otherwise empty lines would get parsed as 0.

I mean, maybe an empty line at the end of the file is needed, FileWrite() adds one, too, IIRC. However, it's definitely not comprehensible for me why MT4 would enter a vicious circle when there is no empty line.


Have you experienced sth. similar or do you where I am wrong?

 
Please expose sample of code to illustrate this problem
 
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
{ 
   int fileHandle = FileOpen("test.txt", FILE_CSV|FILE_READ, ';');
   
   int cnt=0;   // initializing...
   
 //continue since the file is ending
   while(!FileIsEnding(fileHandle))
   {
      if(IsStopped())   // as usual :)
      {
       //a file which has be opened has to be closed some time, right? :D
         FileClose(fileHandle);
         return;
      }
      
      int integer = FileReadNumber(fileHandle);
      Print("read"+integer);
      
  // increase run variable
      cnt++; 
   }
   
   FileClose(fileHandle);      
}