Specifications
Section 9. Program Control Instructions
9-11
statements following Then or Else, the program continues with the statement
following EndIf.
The Else and ElseIf clauses are both optional. You can have as many ElseIf
clauses as you like in a block If, but none can appear after an Else clause. Any
of the statement blocks can contain nested block If statements.
CRBasic looks at what appears after the Then keyword to determine whether
or not an If statement is a block If. If anything other than a comment appears
after Then, the statement is treated as a single-line If statement.
A block If statement must be the first statement on a line. The Else, ElseIf,
and EndIf parts of the statement can have nothing but spaces in front of them.
The block If must end with an EndIf statement.
For Example
If a > 1 And a <= 100 Then
...
ElseIf a = 200 Then
...
EndIf
Tip Select Case may be more useful when evaluating a single expression
that has several possible actions.
If...Then ... Else Statement Example
The example illustrates the various forms of the If...Then...Else syntax.
Dim X, Y, Temp( 5 ) 'Declare variables.
X = Temp( 1 )
If X < 10 Then
Y = 1 '1 digit.
ElseIf X < 100 Then
Y = 2 '2 digits.
Else
Y = 3 '3 digits.
EndIf
. . . . 'Run some code
. . . . 'Run some code
RunProgram ("Device:FileName", Attrib)
Used to run a datalogger program file from the active program file.
Syntax
RunProgram ( "Device:FileName", Attrib )
Remarks
The RunProgram has the following parameters: