As asked by J-F, I am creating this thread about the BASIC interpreter for HP-48/49 I am currently working on. We can discuss specifications (after I'll have them fixed), ask questions, provide benchmarks etc.
Quote:
doesn't allow identifier after NEXT (so, NEXT always closes the inner FOR and FOR/NEXT crossing isn't possible).So how do you exit a for loop early????
- Pauli
I must admit that I don't understand your question. How does variable after NEXT help you to exit a FOR loop early?
For example, we have the following program:
10 FOR I=1 TO 10
20 DISP I
30 NEXT I
40 DISP "I am out!"
How does NEXT I enable a premature exit, compared to NEXT only?
Couldn't you write I=10: GOTO 30 to exit the loop, no matter of NEXT vs. NEXT I?
10 FOR I=1 TO 10
15 IF I=6 THEN I=10: GOTO 30
20 DISP I
30 NEXT
40 DISP "I am out!"
Of course, BASIC-4X, being a highly structured language, provides EXIT and EXIT FOR statements for such purpose:
FOR I=1 TO 10
IF I=6 THEN EXIT
DISP I
NEXT
DISP "I am out!"