next up previous contents index
Next: Element or command attributes Up: Operands in Expressions Previous: Symbolic constants   Contents   Index


Variable labels

Often a set of numerical values depends on a common variable parameter. Such a variable must be defined as a global variable defined by one of

X=expression;
X:=expression;
VECTOR X=vector-expression;
VECTOR X:=vector-expression;
When such a variable is used in an expression, MAD uses the current value of the variable. When the value is a constant or an expression preceded by the delimiter = it is evaluated immediately and the result is assigned to the variable as a constant. When the value is an expression preceded by the delimiter := the expression is retained and re-evaluated whenever one of its operands changes. Example:

L=1.0;
X:=L;
D1:DRIFT,L:=X;
D2:DRIFT,L:=2.0-X;
When the value of X is changed, the lengths of the drift spaces are recalculated as X and 2-X respectively.



MAD User Guide, http://wwwslap.cern.ch/mad/