grandMA3 User Manual Publication
Variables

grandMA3 User Manual » Macros » Variables
Version 2.1

Variables can be used in macros or command line entries.

Variables have a user-defined name that the variable content replaces when the command is executed.

A variable can contain three different types of data:

  • Integer: A signed whole number.
  • Double: A signed fixed-point number with six decimals.
  • Text: Any text string.

Signed numbers can be negative numbers, for instance, -7.

Variables are typeless. This means that an existing variable can be changed to contain a different type.

The name of a variable can be composed of any character. Variable names are case-sensitive.

Hint:
It is not a requirement, but avoiding spaces in variables is a good idea. Instead, consider using camelCase or PascalCase for variable names.

There are two different variable scopes.

Variables can be scoped for the user, or they can be global variables.

User variables can only be seen and used by the user profile that creates them, while global variables can be seen and used by all users in the session.


SetGlobalVariable and SetUserVariable

Creating a variable is the same whether it is a user or global variable, but we use two different keywords to set one or the other: SetGlobalVariable or SetUserVariable.

This is the syntax:

SetGlobalVariable ["Variable_Name"] ["Content text with or without spaces"]

SetGlobalVariable ["Variable_Name"] [Integer or Double]

SetUserVariable ["Variable_Name"] ["Content text with or without spaces"]

SetUserVariable ["Variable_Name"] [Integer or Double]

Important:
The quotation marks are very important if the variable name contains spaces. If the name does not contain spaces, then they can be omitted.
The same is true for text strings as the variable content. Variable content must be in quotation marks to ensure the software stores a text string.

Examples

User name[Fixture]>SetUserVariable MyFavoriteNumber 9
User name[Fixture]>SetUserVariable MyFavoriteText "9"

These two commands create two variables that might seem to have the same content, but the first is a number, and the second is a text. So, it is not because of the names but the quotation marks in the second example.

Single and Double Quotation Marks

It might be needed to store a variable with a text string that includes something in quotation marks. This presents an issue with how the software interprets the input and how it is interpreted when the variable is called during runtime.

The variable system supports single and double quote pairs.

This means that text strings can contain quoted text as long as the other quotation marks are used. 

Examples

Working with a specifically named group ("Spots Grid") in different contexts is necessary. A variable with "Group" and the name can be stored as a variable:

User name[Fixture]>SetUserVariable MySpecialGroup "Group 'Spots Grid' "

Notice the single quotes around the group name and the double quotes around the variable text string. These two pairs can be reversed for the same result.

Now, the variable can be used to address the group:

User name[Fixture]>$MySpecialGroup At 80

The $ is placed before the command so we can recall the variable. 

This is the software's reply:

OK: Group  "Spots Grid"  At  80

GetGlobalVariable and GetUserVariable

The variables' content and type can be listed using the GetGlobalVariable or GetUserVariable keywords.

These keywords need to know what variable to show. The syntax is:

GetGlobalVariable ["Variable_Name"]

GetUserVariable ["Variable_Name"]

These commands show information about the variable name, content type, and content in the Command Line Feedback window.

They only show the variables in their scope. This means that the global version only shows global variables, and the user version only shows the user variables.

This assumes that the variable names are known.

The asterisk (*) wildcard can show all variables or a filtered list of variables for which a part of the name is known.

Examples

The current content of the variable called "MySpecialGroup" can be shown using this command:

User name[Fixture]>GetUserVariable MySpecialGroup

This is the feedback in the command line window:

"MySpecialGroup": Type = Text, Value = "Group 'Spots Grid' "
OK: GetUserVariable  "MySpecialGroup"

The following example shows a list of all the global variables where the name contains the word "Our":

User name[Fixture]>GetUserVariable *ur*

The "O" is replaced with the asterisk to ensure the variables beginning with "Our" are also shown. The asterisk wildcard at the beginning defines that there must be additional letters in front of the letters we specify. In reality, the example will also show variables beginning with "Hour" or, in fact, anything with "ur" somewhere in the name. To specify variables starting with "Our," use the following example:

User name[Fixture]>GetUserVariable Our*

This example shows all the user variables:

User name[Fixture]>GetUserVariable *

Use Variables

Variables are used where the content of the variable is needed. 

The following variable was used in a previous example:

User name[Fixture]>$MySpecialGroup At 80

The variable's text string ("Group 'Spots Grid' ") replaces the $MySpecialGroup. This works because the variable contains a text string with commands.

Important:
Using quotation marks when using variables is essential and makes a difference.

If the variable is used with quotation marks:

User name[Fixture]>$"MySpecialGroup" At 80

This will fail because the content of the variable is explicitly called as a string, and the resulting feedback is:

Illegal object: Fixture  "Group 'Spots Grid'"  At  80

The software tries to use the variable content as a text string and does not interpret it as a command.

This might be useful in other cases. When the variable name contains a text string that should be used as text, it must be in quotation marks. See the example below.

Example

This example uses a variable that contains the name of a group:

User name[Fixture]>SetUserVariable MyGroupName "Spots Grid"

Now, this variable can be used where the text would be used otherwise:

User name[Fixture]>Group $"MyGroupName" At 80

It will fail If the quotation marks are omitted:

User name[Fixture]>Group $MyGroupName At 80
Illegal object: Group  "Spots"  Grid At  80

The text string is interpreted as a command.

Example

Let's assume you are running a musical show with multiple songs that will run off timecode.
The following macro example will create a variable that will be used to set the desk ready for each song.

Opened windows requirement:

  • Macro Pool
  • Pages Pool
  • Timecode Pool
  • Sequence Pool
  • Playbacks
  • Timecode Viewer
  • Sequence Sheet

It could look like this:


For this example, you will need to:

  • Store two sequences, one labeled FirstSong and a second labeled SecondSong. Both sequences should have cue one as the first cue. For more information, see Cues and Sequences.
  • Store two timecode shows, one labeled FirstSong, where the track's target is the sequence labeled FirstSong, and a second timecode show labeled SecondSong, where the track's target is the sequence labeled SecondSong. For more information, see Timecode - View Mode.
  • Assign the sequence labeled FirstSong to page 3 executor 201 and the sequence labeled SecondSong to page 4 executor 201.
  • Store a macro labeled FirstSong.
  • Store a macro labeled SongSetup.

Here's the workflow:

  1. Edit the macro labeled FirstSong.
  2. Insert two macro lines.
  • Macro Line1: First, we need to create a new variable. Edit the command on macro line 1 and type:

This is the feedback in the command history window when the command is executed: 

OK:SetGlobalVariable   "curentsong" "FirstSong"

  • Macro Line 2: Here, we are going to call the macro that we have labeled SongSetup. Edit the command on macro line 2 and type: 

This is what the macro looks like:


Next, we build a macro that will be used throughout the show to set the desk ready for each song.

  1. Edit the macro labeled SongSetup.
  2. Insert eight macro lines.
  • Macro Line 1: Using the new variable "currentsong", we will instruct the software on what page to select. Edit the command on macro line 1 and type: 

This is the feedback in the command history window when the command is executed: 

OKPage "FirstSong"

You can see here that the variable "current song" is replaced with the variable content "FirstSong".

  • Macro Line 2: Now we must instruct the software which executor to select. Edit the command on macro line 2 and type:  

This is the feedback in the command history window when the command is executed: 

OK: Select Page  "FirstSong"  Executor  201

 

  • Macro Line 3: Stop any running timecode is a good idea. To do so, edit the command on macro line 3 and type: 

This is the feedback in the command history window when the command is executed:

OK::Off Timecode  Thru

  • Macro Line 4: Here, we will rewind all timecodes to time 00h00m00.0. Edit the command on macro line 4 and type: 

This is the feedback in the command history window when the command is executed: 

OK: <<< Timecode 1 Thru

Macro Line 5: To select the timecode show, edit the command on macro line 5 and type:  


This is the feedback in the command history window when the command is executed: 

OK: Select Timecode  "FirstSong"

Macro Line 6: Now we instruct the software what timecode show to execute. Edit the command on macro line 6 and type:  


This is the feedback in the command history window when the command is executed: 

OK: Go+ Timecode  "FirstSong"

  • Macro Line 7: Here, we instruct the software to turn off all running executors from page 2 through page 100 except the one running the sequence labeled FirstSong. It's usually a good idea to keep page 1 for any sequences that need to be manipulated manually outside of the running timecode sequences; this is why the command also excludes sequences running on page 1. Edit the command on macro line 7 and type:   


This is the feedback in the command line window:

OK: Off Page  2 Thru  100  "FirstSong"

  • Macro Line 8: Finally, even if the timecode should trigger cue 1, it is safe to add the following command. Edit the command on macro line 8 and type: 

This is the feedback in the command line window:

OK: Go+ Cue  1

This is what the macro looks like:

This is where it gets interesting. To create a macro for the next song:

  1. Copy the macro you have created labeled FirstSong to an empty macro pool object.
  2. Edit that new macro and label it SecondSong.
  3. Edit the command on Macro Line 1 by replacing the variable content "FirstSong" with "SecondSong".

This is what the macro SecondSong looks like:

The only thing that changed is the variable content on Macro Line 1: SetGlobalVariable "currentsong" "SecondSong". So, each time the variable is recalled, it will refer to that new content. This method can be repeated for all songs in the show.

DeleteGlobalVariable and DeleteUserVariable

Variables can be deleted using the DeleteGlobalVariable and DeleteUserVariable keywords.

This is the syntax:

DeleteGlobalVariable ["Variable_Name"]

DeleteUserVariable ["Variable_Name"]

Important:
Deleting a variable cannot be oopsed. There is not much else to say about deleting variables. When deleted, they do not exist anymore.

Concatenate Variables

Variables can be concatenated by storing them into a new variable.

The desired result of the concatenation is to create a compound text string containing the concatenated variables. The output is always a text string. See below for the mathematical addition of number variables.

This is the syntax:

SetGlobalVariable [MyConcatResult] $[VariableName]$[VariableName]

SetUserVariable [MyConcatResult] $[VariableName]$[VariableName]

There must be no space between the variables that need to be concatenated or between any extra text that needs to be part of the concatenation.

Text can be added to the variable in quotation marks with no space between the end and start of quotation marks. However, there can be spaces inside the quotation marks. See the example below.

Examples

These examples use three variables:

Variable Name Content Type Content
MyInteger Integer 9
MyKeyword Text Group
MyGroupName Text Perfect Macro

The goal is to concatenate these into a command string that can be used to store a group.

It can be done with one command but is split up to look at different functions here.

First, the keyword is combined with the integer into a new variable:

User name[Fixture]>SetUserVariable MyCommandString $"MyKeyword"" "$MyInteger

This command uses many quotation marks. Setting the variable names in quotation marks ensures the variable content is interpreted as text. This also means that the integer variable is converted to a text string.

Furthermore, there is a " " between the two variables to add a space between them.

Show results using this command:

User name[Fixture]>GetUserVariable MyCommandString

Next, add the macro name to the string:

User name[Fixture]>SetUserVariable MyCommandString $"MyCommandString"" '"$"MyGroupName""'"

Again, it can be hard to see what is happening. The two names of the variable are in quotation marks. Between the two are a space and a single quotation mark in double quotation marks. After the last variable name, there is another single quotation mark inside the double quotation marks.

Here you can spot them better: SetUserVariable MyCommandString $"MyCommandString"" ' "$"MyGroupName"" ' "

The command looks like this without the double quotations:  SetUserVariable MyCommandString $MyCommandString '$MyGroupName'

The existing content of MyCommandString is added to MyCommandString, plus the content of MyGroupName in single quotations.

The result is that MyCommandString is Group 9 'Perfect Macro' as a text string.

Now, some fixtures can be selected, and this command can be executed:

User name[Fixture]>Store $MyCommandString

Then, a group with the name is stored at group 9. Quotation marks must not be used in the command above.

Variable Addition

Concatenating variables with integer and/or double types performs a mathematical addition instead of an actual concatenation. Here, quotation marks are not used.

The result needs to be stored in a variable.

Examples

This example uses three variables:

Variable Name Content Type Content
MyInteger Integer 9
MySignedInteger Integer -2
MyDouble Double 6.500000

The first two variables can be added to each other with this command:

User name[Fixture]>SetUserVariable MyResult $MyInteger$MySignedInteger

The result can be seen by looking at the command line feedback. It shows that the variable is stored with a value of 7.

The double can be added with an integer. The result will be a double to avoid data loss.

User name[Fixture]>SetUserVariableMyResult $MyInteger$MyDouble

This stores the value of 15.500000 in MyResult.

Type Conversion

Type conversion has been happening in the examples above.

An integer or double can be converted to text by putting the variable name in quotation marks. The command will convert then when it is executed.

Setting variables without quotation marks can convert text to an integer.

An integer can be converted to a double by adding it to a double with the value of 0.000000.

A double cannot be converted to an integer.

Examples

These examples use the following variables:

Variable Name: Content Type: Content:
MyInteger Integer 9
MyEmptyDouble Double 0.000000
MyText Text Hello

This example converts the integer to text:

User name[Fixture]>SetUserVariable MyInteger $"MyInteger"

Converting this back to an integer can be done with the following command:

User name[Fixture]>SetUserVariable MyInteger $MyInteger

Converting an integer to a double can be done using this command:

User name[Fixture]>SetUserVariable MyResult $MyInteger$MyEmptyDouble