next up previous contents index
Next: VALUE: Output of Expressions Up: Parameter Statements Previous: Vector Values   Contents   Index


Assignment to Variables

A value is assigned to a variable or vector by using the function EVAL(real-expression). When seen, this function is immediately evaluated and replaced by the result treated like a constant.

variable-name=EVAL(real-expression);
This statement acts like a FORTRAN or C assignment. The real-expression or vector-expression is evaluated, and the result is assigned as a constant to the variable or vector on the left-hand side. Finally the expression is discarded. The EVAL function can also be used within an expression, e.g.,

vector-name=TABLE(range,EVAL(real-expression));
vector-name={...,EVAL(real-expression),...);
A sequence like the following is permitted:

...                 // some definitions
X=0;                // create variable X with value zero
WHILE (X <= 0.10) {
  TWISS,LINE=...;   // uses X=0, 0.01, ..., 0.10
  X=EVAL(X+.01);    // increment variable X by 0.01
                    // CANNOT use: X=X+.01;
}



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