
How to break out of WHILE ?

pollux
✭
in RobotStudio
Comments
-
You break out of while when the conditions on top are not met0
-
Hi pavpav,Thanks I thought so but will hoping RAPID supported a C-ish `break`. But if that's not possible I'll add it to the while condition.p.0
-
The closest I can think of is the RETURN statement that will exit the current routine. That might work if you put your WHILE statement in a dedicated routine.
Henrik Berlin
ABB0 -
Hey Pollux,You can also use the GOTO statement like this:MODULE WhileLoopVAR num count := 0;PROC TestWhileloop()WHILE TRUE DOIF count > 5 THENGOTO nextPart;ENDIFIncr count;ENDWHILEnextPart:TPWrite "Out of while loop";Stop;ENDPROCENDMODULEhope it helps,LarsLars Glud
Danrob A/S0 -
Ah thanks guys for all the possible solutions!0
-
But then this would do the same with less code and without the use of GOTO which I ware thought never to use when I started programming ABB robots.
MODULE WhileLoopVAR num count := 0;PROC TestWhileloop()WHILE count <= 5 DOIncr count;ENDWHILETPWrite "Out of while loop";Stop;ENDPROCENDMODULEBest regards
Alexander Källberg0
Categories
- All Categories
- 5.5K RobotStudio
- 398 UpFeed
- 19 Tutorials
- 13 RobotApps
- 299 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 324 IRC5
- 63 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 813 RAPID Programming
- 5 AppStudio
- 3 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings