Download MetaTrader 5

how to read the whole string of csv file?

To add comments, please log in or register
bobo1974
216
bobo1974 2016.05.08 10:18 

Hi all,

I have a csv file with 2 variable, equity and time stamp as shown below

10494,2016.05.06 23:55

 

When i try to read the content of the csv file using the script below, it gave me only the equity (10494) which is the "text" variable 

How do i read the whole string which is 10494,2016.05.06 23:55 ?

 

Thanks 

############## 

void ReadCurrentEquityTimeFromFile(){

   int filehandle=0;

   string text;

   

   for (int i=0;i<5;i++){

       filehandle=FileOpen(csvfilename,FILE_READ|FILE_CSV,",");

       if(filehandle!=INVALID_HANDLE) break;

       Sleep(1000);

   }

     

   if(filehandle!=INVALID_HANDLE)

     {

     text = FileReadString(filehandle,0);

     }  

   FileFlush(filehandle);

   FileClose(filehandle);

 

}

bobo1974
216
bobo1974 2016.05.08 10:23  

I manage to resolve it by changing

filehandle=FileOpen(csvfilename,FILE_READ|FILE_CSV,",");

to 

filehandle=FileOpen(csvlastequityfilename,FILE_READ);

bobo1974
216
bobo1974 2016.05.08 12:31  
Alain Verleyen:

noted
Irwan Adnan
925
Irwan Adnan 2016.05.09 15:16  
bobo1974:
noted
Why dont you do what Alain suggest. It makes your code more "readable".
To add comments, please log in or register