EasyManuals Logo

Texas Instruments TI-89 Guide Book

Texas Instruments TI-89
623 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #313 background imageLoading...
Page #313 background image
296 Chapter 17: Programming
17PROGRM.DOC TI-89/TI-92 Plus: Programming (English) Susan Gullord Revised: 02/23/01 1:14 PM Printed: 02/23/01 2:18 PM Page 296 of 40
To execute one group of commands if a conditional test is true and a
different group if the condition is false, use this structure:
: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
A more complex form of the
If
command lets you test a series of
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
, etc.), use the
If...Then...ElseIf...EndIf
structure.
Refer to Appendix A for more information and an example.
You can also control the flow of your program by using
Lbl
(label)
and
Goto
commands.
Use the
Lbl
command to label (assign a name to) a particular
location in the program.
Lbl
labelName
You can then use the
Goto
command at any point in the program to
branch to the location that corresponds to the specified label.
Goto
labelName
Because a
Goto
command is unconditional (it always branches to the
specified label), it is often used with an
If
command so that you can
specify a conditional test. For example:
:If x>5
: Goto GT5
:Disp x
:--------
:--------
:Lbl GT5
:Disp "The number was > 5”
If...Then...Else...
EndIf Structures
If...Then...ElseIf...
EndIf Structures
Lbl and Goto
Commands
name to assign to this location (use the same
naming convention as a variable name)
specifies which
Lbl
command to branch to
Executed only if x>5.
Executed only if x
5.
Displays value of:
2x if x>5.
5x if x
5.
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.

Table of Contents

Other manuals for Texas Instruments TI-89

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TI-89 and is the answer not in the manual?

Texas Instruments TI-89 Specifications

General IconGeneral
Display size (HxV)100 x 160 mm
Memory type639K FLASH ROM, 188K bytes RAM
Compatible operating systemsOperating System 2.09
Battery typeAAA

Related product manuals