Evaluate expression in a .mac file

Hi, I have the following code in a .mac file:

/control/alias initial_alpha -0.01
/gps/ang/mintheta 1.55+{initial_alpha} rad

The expression 1.55+{initial_alpha} seems to be evaluated as 1.55 . The same happens with the expression 1.55-0.01 . With the expression (1.55-0.01) the program doesn’t work properly.

Arithmetic in macro commands is horrible at best. There is no expression interpreter (although CLHEP does provide one, it’s not used by the UI system). Instead, there are macro commands for the four arithmetic operators.

Your code has several issues; here’s what it should look like to do what you want:

/control/alias initial_alpha -0.01    # No brackets around name
/control/add rotated_alpha {initial_alpha} 1.55

/gps/ang/mintheta {rotated_alpha} rad

Note that you can use the same alias name in an arithmetic expression if you want to accumulate a total result, for instance: y = 3*27 + 6

/control/alias y 27
/control/multiply y {y} 3
/control/add y {y} 6

Thank you, that is what I needed.

I wrote in my original question “/control/alias/ {initial_alpha} -0.01”
although in my real code I wrote “/control/alias initial_alpha -0.01” as in your example, sorry about that.
To not confuse the forum users about the source of error, I edited the question.