Campbell CR800 Dokumentacja Strona 245

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 324
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 244
Section 9. Program Control Instructions
Do … Loop
Repeats a block of statements while a condition is true or until a condition
becomes true.
Syntax 1
Do [{While | Until} condition]
[statementblock]
[Exit Do]
[statementblock]
Loop
Syntax 2
Do
[statementblock]
[Exit Do]
[statementblock]
Loop [{While | Until} condition]
The Do...Loop statement has these parts:
Part Description
Do Must be the first statement in a Do...Loop control structure.
While Indicates that the loop is executed while condition is true.
Until Indicates that the loop is executed until condition is true.
condition Numeric expression that evaluates true (nonzero) or false (0
or Null).
statementblock Program lines between the Do and Loop statements that are
repeated while or until condition is true.
Exit Do Only used within a Do...Loop control structure to provide
an alternate way to exit a Do...Loop. Any number of Exit
Do statements may be placed anywhere in the Do...Loop.
Often used with the evaluation of some condition (for
example, If...Then), Exit Do transfers control to the
statement immediately following the Loop. When
Do...Loop statements are nested, control is transferred to the
Do...Loop that is one nested level above the loop in which
the Exit Do occurs.
Loop Ends a Do...Loop
.
Do...Loop Statement Example
The example creates an infinite Do...Loop that can be exited only if Volt(1) is
within a range.
Dim Reply 'Declare variable.
Do
Reply = Volt(1)
If Reply > 1 And Reply < 9 Then 'Check range.
Exit Do 'Exit Do Loop.
EndIf
Loop
9-5
Przeglądanie stron 244
1 2 ... 240 241 242 243 244 245 246 247 248 249 250 ... 323 324

Komentarze do niniejszej Instrukcji

Brak uwag