storing value problem...

 

Hi guys, a little help here?

int handle1,handle2,handle3,handle4,handle5,write;                               // File descriptor
string File_Name1="fractalup.csv";                          // File name
string File_Name3="pastfractalup.csv"; 
string read;
      
//---------------------------------------------------------------------------------------------------------------------
      {
      if(fractalup>0)                                             
         {
         handle4=FileOpen(File_Name3,FILE_CSV|FILE_WRITE,";");   
         FileWrite(handle4,pastfractalup);                           
         FileClose(handle4);
         
         handle1=FileOpen(File_Name1,FILE_CSV|FILE_WRITE,";");   
         FileWrite(handle1,fractalup);                           
         FileClose(handle1);
         
         }
      }
//----------------     
      {
      handle3=FileOpen(File_Name1,FILE_CSV|FILE_READ,";");         //File opening
      read=FileReadString(handle3);
      pastfractalup=StrToDouble(read);
      FileClose(handle3);
      }
   
      {
      handle3=FileOpen(File_Name3,FILE_CSV|FILE_READ,";");         //File opening
      read=FileReadString(handle3);
      pastpastfractalup=StrToDouble(read);
      FileClose(handle3);
      }

i would like to have store 2 value,

when fractalup>0, open file fractalup n write down the fractal, this is then read and equal to pastfractalup, this is done correctly

second i would like to make the the robot to open file pastfractalup.csv, write down the current pastfractalup, and be read as pastpastfractalup. after this, redo again the 1st function.

problem is, what's wrong wif my logic?why the result is pastfractalup = pastpastfractalup in every second

 
shenlongming :

Hi guys, a little help here?

i would like to have store 2 value,

when fractalup>0, open file fractalup n write down the fractal, this is then read and equal to pastfractalup, this is done correctly

second i would like to make the the robot to open file pastfractalup.csv, write down the current pastfractalup, and be read as pastpastfractalup.

Well, I don't really understand what you are trying to achieve but . . .

  {
      handle3=FileOpen(File_Name1,FILE_CSV|FILE_READ,";");         //File opening  //  opens File_Name1 = "fractalup.csv" not "pastfractalup.csv" 
      read=FileReadString(handle3);
      pastfractalup=StrToDouble(read);
      FileClose(handle3);
      }
 
RaptorUK :

Well, I don't really understand what you are trying to achieve but . . .


when fractalup>0, open file fractalup n write down the fractal, this is then read and equal to pastfractalup, this is done correctly

second i would like to make the the robot to open file pastfractalup.csv, write down the current pastfractalup, and be read as pastpastfractalup.

handle3 1st open is to read pastfractalup in fractalup.csv

handle3 2nd open is to read the changed pastpastfractalup in pastfractalup.csv

is it more understandable now?

 

meaning, i would like to store 2 data,

a data(data1) is to be stored (1st csv file)and read,

then it(data1) is stored into second csv file when fractalup>0 is triggered for the second time and is then replace by a new data(data2)

at here, it should be data1 in pastfractalup.csv, n data2 in fractalup.csv,

if it continue, it would be,

data1 in pastfractalup.csv, n data2 in fractalup.csv, each time the condition fractalup triggerred

data2 in pastfractalup.csv, n data3 in fractalup.csv,

data3 in pastfractalup.csv, n data4 in fractalup.csv,

help me please, i'm stuck here

 
shenlongming :

meaning, i would like to store 2 data,

data3 in pastfractalup.csv, n data4 in fractalup.csv,

help me please, i'm stuck here

  1. Start by talking in English - there are no mind readers here.
  2. What is a "n dataX"
  3. What is a "store 2 data," Do you mean two lines, two files.
  4. Until you can explain in proper English what you want, you can't code it.
 
WHRoeder:

Don't Double Post
Double post removed.
 
shenlongming :

meaning, i would like to store 2 data,

a data(data1) is to be stored (1st csv file)and read,

then it(data1) is stored into second csv file when fractalup>0 is triggered for the second time and is then replace by a new data(data2)

at here, it should be data1 in pastfractalup.csv, n data2 in fractalup.csv,

if it continue, it would be,

data1 in pastfractalup.csv, n data2 in fractalup.csv, each time the condition fractalup triggerred

data2 in pastfractalup.csv, n data3 in fractalup.csv,

data3 in pastfractalup.csv, n data4 in fractalup.csv,

help me please, i'm stuck here

So you mean like this . . .

int handle1,handle2,handle3,handle4,handle5,write;                               // File descriptor
string File_Name1="fractalup.csv";                          // File name
string File_Name3="pastfractalup.csv"; 
string read;
      
//---------------------------------------------------------------------------------------------------------------------
  
      if(fractalup>0)                                             
         {
         // read the last fractalup so it can be written to pastfractalup
         handle3 = FileOpen(File_Name1,FILE_CSV|FILE_READ,";");         //File opening
         pastfractalup = 0.0;

         //  check if file is valid
         if(handle3 >= 0)
            {
            read = FileReadString(handle3);
            pastfractalup = StrToDouble(read);
            FileClose(handle3); 
            }         

         handle4=FileOpen(File_Name3,FILE_CSV|FILE_WRITE,";");   
         FileWrite(handle4,pastfractalup);                           
         FileClose(handle4);
         
         handle1=FileOpen(File_Name1,FILE_CSV|FILE_WRITE,";");   
         FileWrite(handle1,fractalup);                           
         FileClose(handle1);
         
         }

Please get into the habit of commenting your code so you know and everyone else knows what it is that you are trying to do, a few comments go a long way . . .