DO digit = 1 TO 3
SAY digit
END
SAY 'Digit is now' digit
DO count = 10 BY -2 TO 6
SAY count
END
SAY 'Count is now' count
DO index = 10 TO 8
SAY 'Hup! Hup! Hup!'
END
SAY 'Index is now' index
Sometimes an infinite loop can occur when input to end
the loop does not match what is expected. For instance, in the example
of using the LEAVE Instruction, what happens when
the input is Quit and a PARSE PULL instruction replaces
the PULL instruction?
PARSE PULL file_name
Results
ANSWERS
The results of the repetitive loops are as follows:
1
2
3
Digit is now 4
10
8
6
Count is now 4
Index is now 10
The program would be unable to leave the loop because Quit is not equal to QUIT. In this case,
omitting the PARSE keyword is preferred because regardless of whether
the input is quit, QUIT, or Quit, the language processor translates the input to uppercase
before comparing it to QUIT.