User`s manual

218 digi.com Keywords
waitfordone
(wfd)
The waitfordone keyword can be abbreviated as wfd. It is part of Dynamic C’s cooperative multitask-
ing constructs. Used inside a costatement or a cofunction, it executes cofunctions and firsttime func-
tions. When all the cofunctions and firsttime functions in the wfd statement are complete, or one of
them aborts, execution proceeds to the statement following wfd. Otherwise a jump is made to the ending
brace of the costatement or cofunction where the wfd statement appears; when the execution thread comes
around again, control is given back to the wfd statement.
The wfd statements below are from Samples\cofunc\cofterm.c
x = wfd login(); // wfd with one cofunction
wfd { // wfd with several cofunctions
clrscr();
putat(5,5,"name:");
putat(5,6,"password:");
echoon();
}
wfd may return a value. In the example above, the variable x is set to 1 if login() completes execution
normally and set to -1 if it aborts. This scheme is extended when there are multiple cofunctions inside the
wfd: if no abort has taken place in any cofunction, wfd returns 1, 2, ..., n to indicate which cofunction
inside the braces finished executing last. If an abort takes place, wfd returns -1, -2, ..., -n to indicate which
cofunction caused the abort.
while
Identifies the beginning of a while loop. A while loop tests at the beginning and may execute zero
or more times.
while( expression ){
...
}