I have a global MACRO defined in .cmm script and I want to get it's value by using the string name.
I tried to reference it with double "&" symbol, but after this line I get an "operand expected" error:
&error_name = STRING.LoWeR("&error_name")+"_low"
&modulus=&&error_name
VAR.IF (FS_ErrorIdStatus[&modulus] != 0)
(
&error_name = "ERR_MON_"+STRing.UPpeR("&error_name")+"_VOLTAGE"
GOSUB TC_DEBUG_MESSAGE " -- FAILED: " + &error_name + " was reported"
RETURN FALSE()
)
Although in the debug window it's value is shown. (https://i.sstatic.net/6wspz.png)
You need two &
on the left side of the assignment. Doing so will cause the macro expansion on the right side to happen twice before the assignment. Example:
&some_macro=0x42
;construct macro name
¯oname="some"+"_macro"
;get value from macro
&&val=&¯oname
PRINT &val
After the first macro replacement run, ¯oname
is replaced with some_macro
, in the second run, &some_macro
is replaced with its value 0x42
which is then assigned to value &val
.