B&B Electronics VFG3000 - Manual User Manual
Page 168
Advertising

P
ROGRAMMING
T
IPS
V
LINX
F
IELDBUS
G
ATEWAY
M
ANAGER
U
SER
M
ANUAL
P
AGE
152
The example below shows the example from above, rewritten to use a
do
loop…
int i:=0, t:=0;
do {
t += Data[i];
} while( ++i < 10 );
return t;
L
OOP
C
ONTROL
Two additional statements can be used within loops. The
break
statement can be used to
terminate the loop early, while the
continue
statement can be used to skip the balance of the
loop body and begin another iteration without executing any further code. To make any sense,
these statements must be used with
if
statements to make their execution conditional. The
example below shows a loop that terminates early if another program returns true…
for( i:=0; i<10; i++ ) {
if( LoopAbort() )
break;
LoopBody();
}
Advertising