Section 9. Program Control Instructions
9-9
If ... Then ... Else Statement
Allows conditional execution, based on the evaluation of an expression.
Syntax 1
If condition Then thenpart [Else elsepart]
Syntax 2
If condition1 Then
[statementblock-1]
[ElseIf condition2 Then
[statementblock-2] ]
[Else
[statementblock-n] ]
End If
Syntax 1 Description
The single-line form is often useful for short, simple conditional tests. Syntax
1 has these parts:
Part
Description
If
Begins the simple If...Then control structure.
condition
An expression that evaluates true (nonzero) or false (0 and
Null).
Then
Identifies actions to be taken if condition is satisfied.
thenpart
Statements or branches performed when condition is true.
Else
Identifies actions taken if condition is not satisfied. If the
Else clause is not present, control passes to the next
statement in the program.
elsepart
Statements or branches performed when condition is false.
The thenpart and the elsepart fields both have this syntax:
{statements | [GoTo] linenumber | GoTo linelabel }
The thenpart and elsepart syntax has these parts:
Part
Description
statements
One or more CRBasic statements, separated by colons.
Note
You can have multiple statements with a condition, but they
must be on the same line and separated by colons, as in the
following statement:
If A > 10 Then A = A + 1 : B = B + A : C = C + B
Syntax 2 Description
The block form of If...Then...Else provides more structure and flexibility than
the single-line form and is usually easier to read, maintain, and debug. Syntax
2 has these parts:
Содержание CR5000
Страница 39: ...Section 1 Installation and Maintenance 1 15 S A N Y O FIGURE 1 11 6 Removal of band clamp and battery ...
Страница 40: ...Section 1 Installation and Maintenance 1 16 This is a blank page ...
Страница 54: ...Section 2 Data Storage and Retrieval 2 14 This is a blank page ...
Страница 88: ...Section 4 CRBasic Native Language Programming 4 12 This is a blank page ...
Страница 94: ...Section 5 Program Declarations 5 6 This is a blank page ...
Страница 172: ...Section 7 Measurement Instructions 7 46 This is a blank page ...
Страница 206: ......
Страница 236: ...Index Index 4 This is a blank page ...
Страница 237: ...This is a blank page ...