for i=1 to 100 do if a[i] = x then location = i exit end if end forIt is also quite common to see something like this:
constant TRUE = 1 while TRUE do ... if some_condition then exit end if ... end whilei.e. an "infinite" while-loop that actually terminates via an exit statement at some arbitrary point in the body of the loop.
If you happen to create a real infinite loop, when using p.exe keying control-c in the console will stop your program immediately. However with pw.exe there may not be a console window, and your only option may be to terminate the process via Windows Task Manager. To avoid that situation you may want to test (gui) programs using p.exe first, or create a console window at the start of the application, for instance by executing a puts(1,"") statement.
The continue statement is closely related. It causes the next iteration to begin immediately, in effect control passes to the end for/end while statement, though you may prefer to think of it as the first statement in the loop - an end while will actually get branch straightened there, however the end for has an increment and test that need to be performed. I will let you guess what this shows:
for i=1 to 5 do printf(1,"%d ",i) if i=3 then puts(1,"is three\n") continue end if puts(1,"is not three\n") end forOne trap for the unwary awaits: adding continue may trigger an infinite loop unless you duplicate the required statement(s) in this kind of while loop:
if alldone then exit end if --\ either something += 1 --/ or both end while