if (logical_expression) {statement 1; statement 2; ...; statement n; }where "logical_expression" is one of
expr1 oper expr2 expr11 oper1 expr12 && expr21 oper2 expr22 expr11 oper1 expr12 || expr21 oper2 expr22and oper one of
== ! equal <> ! not equal < ! less than > ! greater than <= ! less than or equal >= ! greater than or equalThe expressions are arithmetic expressions of type real. The statements in the curly brackets are executed if the logical expression is true.
elseif (logical_expression) {statement 1; statement 2; ...; statement n; }Only possible (in any number) behind an IF, or another ELSEIF; is executed if logical_expression is true, and if none of the preceding IF or ELSEIF logical conditions was true.
else {statement 1; statement 2; ...; statement n; }Only possible (once) behind an IF, or an ELSEIF; is executed if logical_expression is true, and if none of the preceding IF or ELSEIF logical conditions was true.
For a real life example, see ELSE example.
while (logical_condition){statement 1; statement 2; ...; statement n; }executes the statements in curly brackets while the logical_expression is true. A simple example (in case you have forgotten the first ten factorials) would be
option,-info; ! otherwise you get redifiniton warnings n=1; m=1; while (n <= 10) { m = m * n; value, m; n = n + 1; };
For a real life example, see WHILE example.
label: macro = {statement 1; statement 2; ...; statement n; }; label(arg1,...,argn): macro = {statement 1; statement 2; ...; statement n; };The first form allows the execution of a group of statements via a single command:
exec, label;will execute the statements in curly brackets exactly once. This command can be issued any number of times.
The second form allows to replace strings anywhere inside the statements in curly brackets by other strings, or integer numbers prior to execution. This is a powerful construct and should be handled with care.
Simple example:
option,-echo,-info; ! otherwise the output is somewhat confusing simple(xx,yy): macro = { xx = yy^2 + xx; value, xx;}; a = 3; b = 5; exec, simple(a,b);
Somewhat more tricky (a "$" in front of an argument means that the truncated integer value of this argument is used for replacement, rather than the argument string itself).
tricky(xx,yy,zz): macro = {mzz.yy: xx, l = 1.yy, kzz = k.yy;}; n=0; while (n < 3) { n = n+1; exec,tricky(quadrupole,$n,1); exec,tricky(sextupole,$n,2); };Whereas the actual use of the preceding example is NOT recommended, a real life example, showing the full power (!) of macros is to be found under macro usage for the usage, and under macro definition for the definition.
Beware of the following rules:
NOT
exec,thismacro($99,$129);
BUT
n1=99; n2=219;
exec,thismacro($n1,$n2);