Need help: MQL4, FileOpen and while

 

I'm going to learn MQL4 and stumble just a problem to its solution I've found nothing.

It's really only used it that at a certain interval (Sleep) a locally stored CSV file to be opened. This only works 1 time (according to print ()).

int start() {
   csv();
   Sleep (5000);    
}

int csv() {
   
   Print ( "int csv wird ausgeführt" );
   string csv_datei = "test.csv"; 
   handle = FileOpen(csv_file,FILE_CSV|FILE_READ,";");
   while( !FileIsEnding(handle)  ) {
      // ...
    }
    FileClose( handle );
   }
}


My second question:

In the CSV file, there are 2 lines. Read this now I'm with:

...
while ( !FileIsEnding(handle) ) {

   string text1_1       = FileReadString(handle); // 1. Zeile
   string text1_2       = FileReadString(handle); // 2. Zeile
  (...)

}
...

But if I now do not know how many rows the file that has to somehow go dynamically ...

PS: Translated with google. Sorry :/

 
postmann:

I'm going to learn MQL4 and stumble just a problem to its solution I've found nothing.

It's really only used it that at a certain interval (Sleep) a locally stored CSV file to be opened. This only works 1 time (according to print ()).


My second question:

In the CSV file, there are 2 lines. Read this now I'm with:

But if I now do not know how many rows the file that has to somehow go dynamically ...

PS: Translated with google. Sorry :/

Try like this

   string Text_Array [10][100];
   int x, y;

   handle = FileOpen(csv_file,FILE_CSV|FILE_READ,";");
   if (handle > 0)
     {
     x = 0;
     while(FileIsEnding(handle) == false ) 
       {

       y = 0;
       while (FileIsLineEnding(handle) == false)
          {
          y ++;
          Text_Array [x][y] = FileReadString (handle);
          }
       
       //--- further work with the text array if you want

       x ++;
       } 

    FileClose( handle );
    }

 Not compiled not tested

Reason: