RobotStudio event

Datalogging more than 1 line...PLEASE HELP

Hello,

So I am trying to log more than one cycle to a data file.

Here is what I have so far:


MODULE WriteToFile

 

VAR iodev datalog;

VAR string stDate;

VAR string stTime;

 

PROC rCycleTimes() 

IF DInput(JoeyTry)=1 THEN 

stDate:=CDate(); 

stTime:=CTime(); 

Open "HOME:"\File:="SawPart1CT.csv",datalog\Write;

Write datalog,stDate+","+stTime+","+"Cycle Time ="\Num:=ClkRead(CycleClock); 

Close datalog; 

ENDIF

 

IF DInput(JoeyTry)=0 THEN 

stDate:=CDate(); 

stTime:=CTime(); 

Open "HOME:"\File:="SawPart2CT.csv",datalog\Write; 

Write datalog,stDate+","+stTime+","+"Cycle Time ="\Num:=ClkRead(CycleClock); 

Close datalog;

ENDIF 

ENDPROC 

ENDMODULE
For some reason I can only log one instance then nothing else gets logged in the CSV file.
Only one instance logged and there seems to be no way to have it go to the next line in the CSV file as well.
I honestly feel like I am missing something simple. Please help and thank you ahead of time

HAPPY THANKSGIVING AND GOD BLESS
Joey

Best Answers

Answers

  • It looks like you are saying that the next instance overwrites the previous.  That is what I would expect from the code, too.  When you reopen the comdevice, you need to add the optional argument \append , which will add new lines.
    Lee Justice
  • Wow Thank you so much for the fast response!!!


    May I ask, please, where would that \append go in the code?

  • I actually just figured it out when you sent the answer lol. Thank you so much for your help.