LOOP Examples


Example 1:

 

ANSWER

DIM

1

VALID

INIT

"YN"

.

 

 

  

LOOP

 

  

KEYIN

*P01:24,*EL,"Is this correct ? ",ANSWER;

  

SCAN

ANSWER,VALID

  

WHILE

NOT EQUAL

  

DISPLAY

*P01:24,*EL,*B,"INVALID - Try again!";

  

PAUSE

"2"

  

REPEAT

 

 

In this example, the KEYIN/SCAN/DISPLAY loop is repeated until a Y or an N is entered. The same result could be accomplished using UNTIL EQUAL in place of the WHILE NOT EQUAL.

 

Example 2:

 

  

LOOP

 

  

KEYIN

*P01:24,*EL,"Is this correct ? ",ANSWER;

  

SCAN

ANSWER,VALID

  

REPEAT

UNTIL EQUAL

 

In this example, the KEYIN/SCAN loop is repeated until a Y or an N is entered. The same result could be accomplished

using WHILE NOT EQUAL in place of UNTIL EQUAL.

 



PL/B Language Reference LOG10 Example LOWERCASE Examples