Saturday, December 12, 2009

Ways to Program a Loop

If you need a switch to work repeatedly when you run its program, you need to loop it. Here are some ways depending on exactly how you want them to work:
;this strategy repeats indefinitely
to main
loop
[commands to loop]
end

;this strategy makes the program run itself indefinitely
to main
commands to loop
main
end

;this strategy repeats the commands many times
to main
repeat 100
[commands to loop]
end

No comments: