13.07.2015 Views

Turbo Basic

Turbo Basic

Turbo Basic

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DO/LOOP statementFunctionSyntaxDO/LOOP is a loop with a test for TRUE or FALSE at the top and/or bottom of the loop.DO [{WHILEIUNTIL} expression]• statements [EXIT LOOP]Remarks[LOOpIWEND] [{WHILEIUNTIL} expression]expression is a numeric expression, in which nonzero values representTRUE, and zero values FALSE:DO and LOOP are loop builders for all seasons. They allow youto create loops with the test for the terminating condition at the top'of the loop, the bottom, both places, or neither. A DO statementmust always be paired with a, matching LOOP statement at thebottom of the loop. Failure to match DO and, LOOPrt!sults in compile-timeerrors.Use WHILE and UNTIL to add a test to a DO/LOOP. Use theWHILE reserved word if the loop should be repeated if expressionis TRUE, and'terminated. if expression, is FALSE. UNTIL causesthe opposite effect; that is, the loop will be terminated if the conditionis TRUE, and repeated if FALSE.For example:DO WHILE a = 13• statementsLOOPexecutes the statements between DO and LOOP as long as a is 13.DO UNTIL a = 13LOOP• statementsexecutes the statements between DO .and LOOP as long as a isnot 13.At any point in a DO/LOOP you may include an EXIT/LOOPstatement. This, is equivalent to performing a GOTO to the statementafter the terminating LOOP. (For more information; see theEXIT statement.)<strong>Turbo</strong> <strong>Basic</strong> Reference Directory 187

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!