SP4CEBAR 2022-08-10 11:03
IF -1 THEN
GOTO THE_END
END IF
THE_END:
On the TI-84 where I learned about memory leaks in my code, I learned that GOTO works like a portal, if it skips an "END" it is as if there was no "END", however that doesn't seem to be the case here
was8bit 2022-08-10 11:27
my best thoughts...
GOSUBS require a RETURN, matching each GOSUB, or you will eventually crash the program
GOTO simply continues line-by-line execution on a different point...
You will rarely need to use END... but it does come in handy when you need it ;)
Timo 2022-08-10 11:41
Skipping "END IF" is no problem at all.
But, as was8bit said, skipping a RETURN from GOSUB fills up the stack. If you want to jump out of a GOSUB, use "RETURN LABEL" instead of "GOTO LABEL".
SP4CEBAR 2022-08-10 12:28
I was more expecting it to work something like this, I believe this is how it works on TI-84, it's literally like a portal in your code:
IF -1 THEN
GOTO THE_END
END IF
GOTO SKIP
THE_END:
END IF
SKIP:
Timo 2022-08-10 13:07
I think this will give you an "END IF without IF" error.
Probably the TI-84 is a "real" interpreter, which reads and interprets line by line and uses a stack for IF / END IF at run time.
LowRes NX has a preparation step before running a program, where it already checks all the command pairs etc. It also uses a stack for this, but in the preparation step it goes though all lines from top to bottom, ignoring jumps etc.
SP4CEBAR 2022-08-10 14:35
That makes sense, thank you!