cicle for problem

 

hi guys  i have  a  script , this script  read a txt file (with this function, i create a global array aGLineReadHSprd[9999] )

//+------------------------------------------------------------------+
//+                  Read file with global array aGLineReadHSprd[9999]
//+
//+------------------------------------------------------------------+
void ReadFile(string FileName)
  {
   ResetLastError();
   int file_handle=FileOpen(FileName,FILE_READ|FILE_TXT);
   if(file_handle!=INVALID_HANDLE)
     {
      FileReadArray(file_handle,aGLineReadHSprd);
      int size=ArraySize(aGLineReadHSprd);
      FileClose(file_handle);
     }
   else
     {
      Print("File open failed, error ",GetLastError());
     }
  }

load txt inside of  aGLineReadHSprd

in onstart i create  one  for cicle, for  Print all array but  print  some time  5277 to 5890 and jump 9925, not  print all array 0 to 9999  why ????

void OnStart()
  {
   ReadFile(FileCoordinate);
   for (int j=0; j<=ArraySize(aGLineReadHSprd);j++)
   {
   Print (j+" CAZZZZZZZ "+aGLineReadHSprd[j]);
   
   }
   Print("FAFFAAFAFAFAFAF "+aGLineReadHSprd[14]);
   }
 

FileReadArray() can only be used to read from BIN file...

your file is TXT file, you cant use this function.

please read the reference carefully

 

try this one (without an warranty - not tested!).

int readAllLines( const string fName, string &l[], ushort sepLine='\n') { // alternative to FileOpen 
  uchar Bytes[];
  return( FileLoad(fName, Bytes) ? StringSplit(CharArrayToString(Bytes), '\n', l) : 0);
}

It should read the whole file and splits it into lines (l[])