Jump to content

BASIC Programming/Beginning BASIC/Control Structures/DO...LOOP

From Wikibooks, open books for an open world

In the last chapter we learned about inputing data to the program. Well now you'll be learning how to repeat a function over and over again. Remember anything to the right of an apostrophe (') are comments in one version of BASIC, and should be removed, or replaced with a different kind of REMARK, if they cause problems.

CLS 'Clears screen for user

DO 'Starts the Looping process, anything between this and the LOOP command will be repeated.
  PRINT "You will get this message over and over." 'Displays the message "You will get this message over and over."
LOOP ' Shows where objects should stop being looped.

This loop will continue forever, unless interrupted by the operating system. If you wanted to have a condition where the loop ends, you can put a WHILE or UNTIL keyword after LOOP.