Other Content

Table Of Contents
502 Getting Started with the Program Editor
Control structures such as If...EndIf commands use a conditional test to
decide which part of a program to execute.
Loop commands such as For...EndFor repeat a group of commands.
Using If, Lbl, and Goto to Control Program Flow
The If command and several If...EndIf structures let you execute a statement or
block of statements conditionally, that is, based on the result of a test (such as
x>5). Lbl (label) and Goto commands let you branch, or jump, from one place to
another in a function or program.
The If command and several If...EndIf structures reside on the Program Editor’s
Control menu.
When you insert a structure such as If...Then...EndIf, a template is inserted at
the cursor location. The cursor is positioned so that you can enter a conditional
test.
If Command
To execute a single command when a conditional test is true, use the general
form:
If x>5
Disp "x is greater than 5"À
Disp xÁ
À
Executed only if x>5; otherwise, skipped.
Á
Always displays the value of x.
In this example, you must store a value to x before executing the Ifcommand.
If...Then...EndIf Structures
To execute one group of 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Á
À
Executed only if x>5.