FileReadString() problem

To add comments, please log in or register
David Rodriges
136
David Rodriges  

Hello,


need help:

if I create and save a file with FileWrite(), I can read it out with FileReadString(). This wokrs als long as the EA is running properly. 


My problem is that I cannot call the generated files when I stop and start the program. 


There is data that i would like to load after restating the PC. That´s why I save it in a CSV file.


my code to save:

void Safe(){

   for(int j=0;j<5;j++){
      for(int i=0;i<8;i++){
         string text= "w1["+j+"]["+i+"].csv";
         int hh=FileOpen(text,FILE_WRITE|FILE_ANSI|FILE_CSV,";");
         if(hh==INVALID_HANDLE){
            Alert("Error opening file");
            return;
         }                           
         FileWrite(hh,DoubleToString(w1[j][i]));       
         FileClose(hh);
      } 
   }
   Alert("Gewichte gespeichert");
}



Read code:

void Read(){
   for(int j=0;j<5;j++){
      for(int i=0;i<8;i++){
         string text= "w1["+j+"]["+i+"].csv";
         int hh=FileOpen(text,FILE_READ|FILE_ANSI|FILE_CSV,";");
         if(hh==INVALID_HANDLE){
            Alert("Error opening file");
            return;
         }                           
         w1[j][i]=StringToDouble(FileReadString(hh));       
         FileClose(hh);
      } 
   }
   Alert("Gewichte geladen");
}
Seng Joo Thio
1758
Seng Joo Thio  
David Rodriges:

Hello,

need help:

if I create and save a file with FileWrite(), I can read it out with FileReadString(). This wokrs als long as the EA is running properly. 

My problem is that I cannot call the generated files when I stop and start the program. 

There is data that i would like to load after restating the PC. That´s why I save it in a CSV file.

my code to save:

Read code:

Your code looks fine. What's the error?

To add comments, please log in or register