next up previous contents index
Next: Lines and Sequences Up: The MAD Program Previous: Variables and constants

Subsections


Program Flow Control

If Statements

IF statements can now be written like in C:

IF (X < 10) {
   LAG = 0.0;
} ELSE {
   LAG = 0.5;
}
The expression folllowing IF is a <logical expression>

While Statements

WHILE statements can now be written like in C:

X = 0;
WHILE (X < 10) {
   SHOW, NAME = QF & STRING(X);
   X = X + 1;
}
The expression folllowing WHILE is a <logical expression>

Macros

The subroutines of MAD-8 have been replaced by the MACRO construct, which allows arguments to be handed over:

// MACRO DEFINITIONS:
SHOWIT(X): MACRO {
   SHOW, NAME = X;
}
DOIT(): MACRO {
   DYNAMIC,LINE=RING,FILE="DYNAMIC.OUT";
}

// MACRO CALLS:
SHOWIT(PI);
DOIT();
An empty parameter list must be indicated by (). Macros can occur anywhere in the input. However, a macro expansion always produces zero or more complete statements.



chris.iselin@cern.ch