PROGRAM FILE 46: INTERACTION OF CONTROL STATEMENTS WITH
        THE FOR-STATEMENT.
    ANSI STANDARD 11.2, 11.4, 10.2, 10.4

SECTION 46.1: INTERACTION OF GOSUB-STATEMENT WITH
        THE FOR-STATEMENT.

THIS SECTION TESTS THAT A GOSUB ROUTINE CAN BE EXPECTED
FROM WITHIN A FOR-BLOCK.

               BEGIN TEST.

CONTROL VARIABLE:
SHOULD BE      ACTUAL         RESULT
 8              8               OK  
 4              4               OK  
 0              0               OK  
-4             -4               OK  
LOOP EXITED
-8             -8               OK  

NO. TIMES THROUGH LOOP:
SHOULD BE:  4      ACTUAL:  4     RESULT:   OK  

*** TEST PASSED ***

               END TEST.

SECTION 46.2: FOR-LOOPS WITH SAME CONTROL-VARIABLE
        NESTED DYNAMICALLY WITH GOSUB.

THIS SECTION TESTS THAT A GOSUB ROUTINE CAN BE EXECUTED
FROM WITHIN A FOR-BLOCK AND THAT THE SUBROUTINE MAY ITSELF
CONTAIN A FOR-BLOCK. IF THE TWO FOR-BLOCKS USE THE SAME
CONTROL-VARIABLE, THE ORIGINAL VALUE IS LOST.

               BEGIN TEST.

CONTROL VARIABLE:
SHOULD BE      ACTUAL         RESULT
ENTERING OUTER LOOP
 8              8               OK  
ENTERING INNER LOOP
-10            -10              OK  
-8             -8               OK  
INNER LOOP EXITED
-6             -6               OK  
OUTER LOOP EXITED
-9             -9               OK  

NO. TIMES THROUGH INNER LOOP:
SHOULD BE:  2      ACTUAL:  2    RESULT:   OK  


NO. TIMES THROUGH OUTER LOOP:
SHOULD BE:  1      ACTUAL:  1    RESULT:   OK  

*** TEST PASSED ***

               END TEST.


SECTION 46.3 CONTROL-STATEMENT JUMPS OUT OF FOR-BLOCK.

THIS SECTION TESTS THAT YOU CAN JUMP OUT OF A FOR-BLOCK
AND THAT THE CONTROL-VARIABLE RETAINS ITS VALUE WHEN
THIS HAPPENS.

             BEGIN TEST.

LOOP IS: FOR I1= 33  TO  66  STEP  4 

CONTROL VARIABLE:
SHOULD BE      ACTUAL         RESULT
 33             33              OK  
 37             37              OK  
 41             41              OK  
 45             45              OK  
 49             49              OK  
 53             53              OK  
 57             57              OK  
 61             61              OK  
JUMPED OUT OF LOOP
 61             61              OK  

NO. TIMES THROUGH LOOP:
SHOULD BE:  8      ACTUAL:  8      RESULT:   OK  

--------------------------------------

LOOP IS: FOR I1= 7  TO  7  STEP  0 

CONTROL VARIABLE:
SHOULD BE      ACTUAL         RESULT
 7              7               OK  
 7              7               OK  
 7              7               OK  
 7              7               OK  
 7              7               OK  
JUMPED OUT OF LOOP
 7              7               OK  

NO. TIMES THROUGH LOOP:
SHOULD BE:  5      ACTUAL:  5     RESULT:   OK  

***  TEST PASSED  ***

               END TEST.

END PROGRAM 46

Program interrupted at line 3080
