TeleFlow BasicScript DoWhileLoop
From TeleFlow
Executes one or more statements in the loop created by DO … LOOP until certain conditions are met as described by the WHILE or UNTIL statement or until an EXIT DO is reached.
Syntax
DO EXIT DO LOOP DO WHILE condition [EXIT DO] LOOP DO UNTIL condition [EXIT DO] LOOP DO [EXIT DO] LOOP WHILE condition DO [EXIT DO] LOOP UNTIL condition
condition: a BasicScript statement that results in a numeric value. condition is said to succeed if the value is not zero and to fail if the value is zero. The WHILE BasicScript keyword will continue a DO loop until condition fails (value is zero). The UNTIL BasicScript keyword will continue a DO loop until a condition succeeds (value is not zero). If the WHILE or UNTIL keyword is found after the DO, condition is evaluated prior to the entry of the DO loop (meaning that there may be no execution of the content of the DO loop based on the result of condition). If the WHILE or UNTIL keyword is found after the LOOP, condition is evaluated only after the first loop. The WHILE and UNTIL keywords are optional and exclusive. If the DO loop does not contain a WHILE and UNTIL keyword, the EXIT DO is expected to escape the DO loop, otherwise the execution of the code would result in an infinite loop. Note that the syntax of EXIT WHILE and EXIT UNTIL are equivalent to EXIT DO to promote code readability.
Related Steps
Examples
BasicScript code Result PRINT "start" start @A = 1 1 DO 2 PRINT("@A") 3 @A = @A + 1 4 LOOP UNTIL (@A>=5) 5 PRINT "end" end PRINT "start" start @A = 10 10 DO PRINT("@A") end @A = @A + 1 LOOP WHILE (@A<=5) PRINT "end" PRINT "start" start @A = 1 1 DO UNTIL (@A>=5) 2 PRINT("@A") 3 @A = @A + 1 4 LOOP end PRINT "end" PRINT "start" start @A = 1 1 DO WHILE (@A<=5) 2 PRINT("@A") 3 @A = @A + 1 4 LOOP 5 PRINT "end" end PRINT "start" @A = 10 start DO WHILE (@A<=5) end PRINT("@A") @A = @A + 1 LOOP PRINT "end" PRINT "start" @A = 10 start DO WHILE (@A>=5) end PRINT("@A") @A = @A + 1 LOOP PRINT "end" PRINT "start" @A = 1 start DO 1 PRINT("@A") 2 @A = @A + 1 3 IF @A >= 5 THEN 4 EXIT DO 5 END end LOOP PRINT "end"
