UNDO handler behavior with Exit and ExitCycle instructions
DBrowne
✭
in RobotStudio
I'm trying to use an UNDO handler to ensure that a procedure is cleaned up properly. Inside that procedure, I'm calling another procedure that may perform a call to the Exit or ExitCycle instructions. I wanted to ensure that the UNDO code would still be executed under these conditions and discovered some inconsistent behavior.
Using the code attached below, I get the following printed to TP:
> Calling Exit
> Undone
However if I replace Exit with ExitCycle, I only get the following:
> Calling Exit
So the UNDO handler isn't getting executed when ExitCycle is called, even though the PP is being prematurely moved out of the routine. I'm wondering if this is intended behavior, and if so why this isn't mentioned in the documentation. Here's an excerpt:
Using the code attached below, I get the following printed to TP:
> Calling Exit
> Undone
However if I replace Exit with ExitCycle, I only get the following:
> Calling Exit
So the UNDO handler isn't getting executed when ExitCycle is called, even though the PP is being prematurely moved out of the routine. I'm wondering if this is intended behavior, and if so why this isn't mentioned in the documentation. Here's an excerpt:
UNDO is activated when the program pointer is unexpectedly moved out of an UNDO-routine, for instance if the user moves the program pointer to Main. UNDO is also started if an EXIT instruction is executed, causing the program to be reset, or if the program is reset for some other reason, for instance when changing some configuration or if the program or module is deleted. However, UNDO is not started if the program reaches the end of the routine or a RETURN statement and returns as usual from the routine.
PROC main() TestUndo; ENDPROC PROC TestUndo() CallExit; UNDO TPWrite "Undone"; ENDPROC PROC CallExit() TPWrite "Calling Exit"; Exit; ENDPROC
0
Categories
- All Categories
- 5.5K RobotStudio
- 395 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings