Skip to content

Conditional expressions

In some situation you may want to only process a command, if the user has answered something specific in a popup, or if a variable is set to a specific value.

The grandMA2 supports simple conditional expressions, which must resolve to β€œTrue” for the following command line to be executed.

Example:

No.CMD
1SetVar $answer=(β€œReally delete all groups? yes/no”)
2[$answer==β€œyes”] Delete Group Thru

This macro will create a pop-up asking if you want to delete all groups. The answer is stored in a variable. Then the variable content is compared to a text string. If they are equal then the rest of the macro line is executed. If they are not equal then the rest of the line is ignored and the macro will continue to the next line if there are more.

Β 

Conditional expressions are recognized by Square Brackets, and accept the following logical operators:

  • a == b
    a equals b
  • a > b
    a greater than b
  • a < b
    a less than b
  • a <= b
    a less than or equal b
  • a >= b
    a greater than or equal b

Β 

Important:
The two arguments a and b are not compared as numbers, but as text-strings, character by character, e.g. β€œ61” is considered to be greater than β€œ599”, as 6 is larger than 5.