0

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.stack.imgur.com/6wspz.png)

Ondina
  • 3
  • 2

1 Answers1

1

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
&macroname="some"+"_macro"

;get value from macro
&&val=&&macroname

PRINT &val

After the first macro replacement run, &macroname is replaced with some_macro, in the second run, &some_macro is replaced with its value 0x42 which is then assigned to value &val.

Reinhard Weiss
  • 426
  • 2
  • 4