Skip to content
Property Value
Hex Value $D6
Categories
Localizations
  • FR: Lbl

Lbl

Overview

Creates a label of one or two characters.

Availability: Token only available from within the Basic editor.

Syntax

Lbl label

Arguments

NameTypeOptional
label

Location

prgm, CTL, 9:Lbl


Description

The Lbl command is used together with the Goto command to jump (or branch) to another place in a program. When the calculator executes a Goto command, it stores the label name in memory, and then searches from the beginning of the program for the Lbl command with the supplied name. If it finds it, it continues running the program from that point; otherwise, if the label does not exist, it throws a ERR: LABEL error.

Label names can be either one or two characters long, and the only characters you're allowed to use are letters (including θ) and numbers 0 to 9; this means 37+37*37=1406 possible combinations. Of course, you should use all of the single character names first, before using the two character names. While you can technically have the same label name multiple times in a program, it is rather pointless since the calculator always goes to the first occurrence of the label.

You can position a Lbl command one or more lines before a Goto command to create a kind of loop structure. However, you have to provide the break-out code, since it isn't built-in. An If conditional is easiest, but if there is no code that ends the branching, then program execution will continue indefinitely, until you manually exit it (by pressing the ON key).

:Lbl A
:...
:If <exit condition>
:Goto A  // this line is skipped

Although the Lbl/Goto loop structure may seem like a good alternative to loops, it should be avoided whenever possible, which is especially important when you are first planning a program. This is because it has several serious drawbacks associated with it:

  • It is quite slow, and gets slower the further the Lbl is in your program.
  • It makes reading code (your own, or someone else's) much more confusing.
  • In most cases, If, For(, While, or Repeat can be used instead, saving space and improving speed.
  • Using a Goto to exit any block of code requiring an End command causes a memory leak — around 40 bytes of memory will be rendered useless each time you do it until the program finishes running, which will also slow down your program down.

They aren't all bad, however, and are actually useful when a loop isn't practical and when something only happens once or twice. Just remember that you should never use Goto to repeat a block of code several times. Use For(, Repeat, or While instead.

Labels are also used with the Menu( command. The same considerations apply as with Goto, except that (unless you write a custom menu routine) there's no simple alternative to using labels with Menu(.

Error Conditions

  • ERR:INVALID is thrown if this statement is used outside a program.
  • ERR:LABEL is thrown if the corresponding label doesn't exist.

Source: parts of this page were written by the following TI|BD contributors: burr, DarkerLine, GoVegan.

History

Calculator OS Version Description
TI-82 1.0 Added
Authors: Adrien Bertrand