Chapter 17: Programming      295
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 295 of 40
To enter 
If...EndIf
 structures, use
the Program Editor’s 
„
 
Control
toolbar menu.
The 
If
 command is available
directly from the 
„
 menu.
To see a submenu that lists other
If
 
structures, select 
2:If...Then
.
When you select a structure such as
If...Then...EndIf
, a template is
inserted at the cursor location.
:If 
 Then
:EndIf
To execute only one command if a conditional test is true, use the
general form:
:If x>5
:   Disp "x is greater than 5"
:Disp x
In this example, you must store a value to 
x
 before executing the
If
 
command.
To execute multiple commands if a conditional test is true, use the
structure:
:If x>5 Then
:  Disp "x is greater than 5"
:  2
ù
x
!
x
:EndIf
:Disp x
Using If, Lbl, and Goto to Control Program Flow
An 
If...EndIf
 structure uses a conditional test to decide
whether or not to execute one or more commands. 
Lbl
 (label)
and 
Goto
 commands can also be used to branch (or jump)
from one place to another in a program.
„
 
Control Toolbar
Menu
If Command
Tip: Use indentation to
make your programs easier
to read and understand.
If...Then...EndIf
Structures
Note: 
EndIf
 marks the end
of the 
Then
 block that is
executed if the condition is
true.
Executed only if x>5;
otherwise, skipped.
Always displays the value of x.
Executed only if x>5.
Displays value of:
• 
2x if x>5.
• 
x if x
5.
The cursor is positioned so
that you can enter a
conditional test.