TI-Basic Z80 Programming/Goto and Lbl

Goto ( CTL 0) and Lbl ( CTL 9) are used to jump to different sections in the program. However, these should be used sparingly, since having many Gotos can make the program very convoluted and difficult to understand.

Syntax and Usage
When the program executes a Goto statement, it jumps to the corresponding Lbl with the same label. If the specified Lbl does not exist, a label error is thrown.

For example, observe the following program:

You may think that this program will display. However, the following is actually displayed:

This is because after the <tt>Disp</tt> command after the first <tt>Lbl</tt>, the program continues past the second <tt>Lbl</tt> and continues executing statements. To prevent the program from continuing to execute instructions, <tt>Stop</tt> (<tt> CTL G</tt>) can be used, which simply stops the current program.

This modified program simply displays: