Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?

LOOP

Description

The LOOP construct allows the programmer to specify loops with multiple exit conditions. The construct takes the general form: 

LOOP statements1 WHILE|UNTIL expression DO statements2 REPEAT

 Where:

  • statements1 and statements2 consist of any number of standard statements including  the LOOP statement itself, thus allowing for nested loops. statements1 will always be executed at least once, after which the WHILE or UNTIL clause is evaluated.
  • expression is tested for Boolean TRUE/FALSE by either the WHILE clause or the UNTIL clause.

When tested by the WHILE clause statements2 will only be executed if expression is Boolean TRUE. When tested by the UNTIL clause, statements2 will only be executed if the expression evaluates to Boolean FALSE. .

REPEAT causes the loop to start again with the first statement following the LOOP statement. An example of use is as: 

loop
    input answer,1 until NUM(answer)   
repeat 

to keep asking for an input till the user enters a numeric value. 


See also: BREAK, CONTINUE 

Go back to jBASE BASIC.

Was this article helpful?