The Practical Guide to Variables

Variables are small stores used to keep track of various types of data. These data stores can be easily recalled and used in CueScript in any context.

There are a plethora of situations where variables can be helpful and multiple ways in which they can be used.

This article is here to help you determine what those situations might be and the multitude of ways they can be utilized.

 

For a more in-depth technical analysis on user variables, check out the variables section of the manual.

For more on System Variables, used for setting system parameters and settings, take a look at this section.

The Guide

We'll go through variables, their types, and how you can use them. Use the list below to jump ahead or follow along from the beginning.


Two Types of Variables

In CueScript, there are two types of variables, they are described below along with an example of each.

 

System Variables

These variables are pre-set and used to manipulate system settings and properties.

An example of a System Variable would be audio.volume which is used to set CueServer's system output volume.

User Variables

These variables are defined by the user and are used to store small pieces of data, such as strings, numbers, channel ranges, commands and much more.

An example of a User Variable might be "fixtureOne" and used to store the value of ch1>3. The Use for this might be to recall a fixture's channel range quickly without the need to remember actual channel addresses.


Setting Variables

In CueScript, there are two ways to declare a variable, using the Set command, or "double quotes".
Additionally, you can set or change a variable using the variables panel in CueServer Studio.


Using the Set Command

The set command is a command that takes two parameters, separated by spaces.
The first parameter is the variable name and the second is the value

For example, to set the variable myVariable to 1, the command would be:

set myVariable 1

Using Double Quotes

The simplest way to set a variable is to use double quotations around the variable name followed by = and the value.

For example, to set the variable myVariable to 1, the command would be:

"myVariable" = 1

Using the Interface

To use the interface, you click on the variables panel, then use the + button to create and set the variable.


Try it out!

Use the demo to create and set variables,
or click either of the buttons below to see an example.

Variables
VariableDefault ValueCurrent ValueNon-Volatile
Playback: 1Time: NoneTarget: NoneStack: DefaultZone: NoneStation: DefaultPage: None

Recalling Variables

You can recall variables and use them as values, modifiers, or selectors using single quotes.


Anywhere in CueServer, call a variable's value into place using single quotes.

Channel 1 at 'myVariable'

Channel one is set to the numerical value of the variable myVariable


Executing Variables

You can use variables to store CueScript Commands as well and execute them with backticks.


Anywhere in CueServer, call a variable's value into place and execute it using back-ticks.

Set a variable like so:

"myVariable" = "channel 1 at 100"

Now we can execute this variable as a command like so:

`myVariable`

Essentially, this method turns a variable into a sort of Macro, or User-Defined Function.

One reason this might be useful is in the event where you have a series of commands that are repeated throughout a show. This allows you to simplify the code and make future changes or blanket edits much more easily.


Using Variables with Strings

You can use variables to concatinate or construct strings in CueScript.


There are two ways to use variables with strings in CueScript. The first is to use parenthasees and the + operator.

For example:

"myChannelVariable" = 5
"myStringVariable" = ("Channel " + 'myChannelVariable')

The result of which being that the value of myStringVariable is set to "Channel 5"


The second way to use variables with strings is to use the variable escape sequence:

"myStringVariable" = "Channel ${myChannelVariable}"

This results in the same string as above, but with a more simplified syntax.

Have a Tip or Trick you would like to see? Let us know!

We hope you enjoyed this Tip & Trick, and as always, if you ever have any suggestions or ideas that you would like to see
featured, shoot us an email at support@interactive-online.com and let us know!