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

From Wikibooks, open books for an open world
Jump to: navigation, search

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 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.