Campbell CR800 Dokumentacja Strona 249

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 324
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 248
Section 9. Program Control Instructions
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] ]
EndIf
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:
9-9
Przeglądanie stron 248
1 2 ... 244 245 246 247 248 249 250 251 252 253 254 ... 323 324

Komentarze do niniejszej Instrukcji

Brak uwag