RobotStudio event

Close files on user stop


Hi,

in my program some files are opened at the beginning and data is continually written to and read from these files. The files are closed before ENDPROC.

How can these files be closed when the user stops execution of the program? UNDO doesn't work in this case.

Any help appreciated!

Regards,
Michael

Comments

  • Hi Michael,

    You need to have a background task (which runs continuously while the controller is powered) to manage communication with the files.
    Your foreground task would pass data to the background task for writing.
    The background task would monitor execution of the foreground task and close the files when execution stops.
    You will need the 'Multitasking' RobotWare option in your controller in order to do this.

    Regards,

    Kevin


  • Thanks for the tip Kevin, I'll see into this after the weekend :-)

    Best regards,
    Michael

  • ...if you don't have Multitasking, take a look at Event Routines for the "STOP" event. This is a way to trig a Rapid routine when a specific event occur. Event routines are set up in the Controller section of the System parameters. It might be a good idea to declare the routine in a system module.