continue to next loop

Use: continue
Description: Skip rest of loop and continue on to the next loop iteration
Parameters: None
Returns: None
Related: for, whileifif else, break

The continue command is used inside a for or while loop to skip to the next loop iteration. The program will skip the rest of the loop and continue at the first command at the top of the loop.


pindir(P1_3, INPD)
print 'You can have some candy in 10 seconds'
print '  Press the switch if you just cant wait that long!' 
a = 10
while a > 0:               # Run the loop, each time reducing a by 1
    print a
    a = a - 1
    if inp(P1_3) == 0:     # Look at the switch, if pressed the value will be 0
        continue           # continue and skip the rest of the loop
print ' ... have this M&M'

When the above example runs it will run through the loop once every 1000ms decreasing a by one each time, but if the switch on P1_3 is pressed it will cause the program to continue to the next loop. The continue command will cause the program to continue execution at the start of the while or for loop.