Ozapell Basic Learn Programming #5

In addition to the FOR NEXT statement(s) discussed previously, there are two more logical flow controlling statements.

The first is WHILE ENDWHILE. If the variable or data provided is TRUE, the code will execute. If it is FALSE, then WHILE will jump to the ENDWHILE and the loop will end.

Example:

VALID=TRUE

WHILE VALID

PRINTLINE “VALID”

VALID=FALSE

ENDWHILE

In this example, the loop will execute only once. If it had been WHILE TRUE, there would have been an infinite loop which could only be stopped by pressing [ESC] on the keyboard.

The second logical flow control statement(s) is REPEAT UNTIL. Unlike WHILE ENDWHILE which may never execute, REPEAT UNTIL will always execute its loop at least once. When the variable or data provided at UNTIL is TRUE, the loop will end.

Second example:

DONE=TRUE

REPEAT

PRINTLINE “OUTPUT”

UNTIL DONE

In this example, the loop will execute only once. If DONE had been assigned FALSE, the loop would be infinite and would require the pressing of [ESC] on the keyboard to end.

Ozapell Basic on Steam

 

Advertisements
Ozapell Basic Learn Programming #5

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s