Texas Instruments TI-89 Manual Book page 313

Ti ti-89: user guide
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

If...Then...Else...
EndIf Structures
If...Then...ElseIf...
EndIf Structures
Lbl and Goto
Commands
296
Chapter 17: Programming
To execute one group of commands if a conditional test is true and a
different group if the condition is false, use this structure:
Executed only if x>5.
Executed only if x5.
Displays value of:
2x if x>5.
5x if x5.
A more complex form of the
conditions. Suppose your program prompts the user for a number
that corresponds to one of four options. To test for each option
(
,
If Choice=1
If Choice = 2
structure.
Refer to Appendix A for more information and an example.
You can also control the flow of your program by using
and
commands.
Goto
Use the
command to label (assign a name to) a particular
Lbl
location in the program.
Lbl labelName
name to assign to this location (use the same
naming convention as a variable name)
You can then use the
Goto
branch to the location that corresponds to the specified label.
Goto labelName
specifies which Lbl command to branch to
Because a
Goto
command is unconditional (it always branches to the
specified label), it is often used with an
specify a conditional test. For example:
If x>5, branches directly to
label GT5.
For this example, the program
must include commands (such
as Stop) that prevent Lbl GT5
from being executed if x5.
:If x>5 Then
: Disp "x is greater than 5"
: 2ù x! x
:Else
: Disp "x is less than or
equal to 5"
: 5ù x! x
:EndIf
:Disp x
If
command lets you test a series of
, etc.), use the
If...Then...ElseIf...EndIf
command at any point in the program to
If
command so that you can
:If x>5
: Goto GT5
:Disp x
:--------
:--------
:Lbl GT5
:Disp "The number was > 5"
(label)
Lbl

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92 plusTi-92 plus

Table of Contents