|
||
| Contents -> USER MANUAL AND TUTORIALS -> Introduction To the spec User Interface -> Flow Control | |
| spec Manual | |
1.3.5. - Flow ControlFlow control allows you to construct complex scans and other macros to control experiments and take data. The syntax of the flow control is very similar to standard C. For example, to list all the motor positions, you can use the following loop: 1.FOURC> for (i = 0; i < MOTORS; i++) {As in C, the for
statement contains within parentheses three optional expressions
separated by semicolons.
The first expression is executed before entering the loop.
The second is the test done before each pass
of the loop -- if it evaluates false, the loop is terminated.
The third expression is executed at the end of each loop.
The conditional statements if ( condition ) statementand if ( condition ) statement else statementare also available. For example, to test whether a variable has been assigned a value, you could examine the return value of the built-in whatis()
function (described
2.4.1.2
in the
Reference Manual).
1.FOURC> if (whatis("DATAFILE")>>16&0x8000)When there is a solitary if
statement,
a semicolon,
extra newline or some other command
must be read
before the
if statement
will be executed,
as it is not clear to the parser whether
an
else statement will follow.
If there is an
else
statement, it must follow the
if portion of the statement on the next line.
1.FOURC> if (whatis("DATAFILE")>>16&0x8000)The while
construction is also available.
Usage is
1.FOURC> while (wait(0x22)) {As in C, continue
and
break
statements
may be used within loops.
The statement
exit can be used anywhere and always causes a jump
back to the command level.
|
Top
|
|
Prev | Next
|
|