Skip to content

Logical Sequences

Using logical sequences

When started, a logical sequence executes its events as quickly as possible. Compared to timed sequences, there is no pre-roll, pre-conditions, or times associated with each event. Logical sequences are also able to run some events that timed sequences are not, like 'If' and 'Goto'.

Logical sequences are commonly used for a variety of tasks, like updating the front panel display, monitoring device status, updating show variables, or virtually any operation that doesn't require precise frame-by-frame timing. A rule-of-thumb is that if you need something happen in perfect sync inside your device, or in concert with another device, use a timed sequence. Otherwise, a logical sequence is likely the right and more flexible choice.


ScriptOS is a highly efficient operating system, but it's still good programming practice to rate-limit sequences and operations that don't need to happen every frame. The Delay event is an excellent way to do that.

The 'Delay' event will pause processing a logical sequence for a specified number of frames. This allows the sequence to yield its processing time and prevent the sequence from running more often than needed. For instance, a logical sequence for monitoring projector lamp status might use a 300 frame delay to only run every 5 seconds.

Execution speed

By default, logical sequences execute as quickly as possible. However, there might be times when this isn't the desired behavior. A good example of this is communicating with external devices, where it takes time for a message to reach the external device and a get a response back. In this case, you might want to the logical sequence to wait for the response before executing the remainder of the sequence.

When "Wait for Device Responses" is enabled in the sequence options dialog, the logical sequence will wait on any external device event until a response is received from that device. For example, if you have an event requesting the shutter status from a projector, the next event won't execute until the shutter status response is received.

In the example above, the logical sequence will wait for a response from the ShowTouch at line 1 before continuing to line 3, where it checks the ShowTouch_1.Error device variable.

Device responses are processed once a frame, after sequence processing. This means a logical sequence that is waiting for a device response will not continue until at least 1 frame has passed.

If wait for responses was not enabled, the sequence could continue immediately after sending a command to the device, but the ShowTouch_1.Error variable would not yet be updated. Another way to wait for a response would be to create a trigger to check when ShowTouch_1.Error is set instead of using an If = event to check within the logical sequence itself.

Control Flow

One unique feature of logical sequences is the ability to execute Control Flow events like If and Goto. This lets you use a logical sequence to execute complicated logic, similar to a function in a programming language.


For those of you familiar with programming languages like C or Python, it's tempting to treat logical sequences like functions, and indeed they can be used in a similar fashion. BUT, it's important to remember that ScriptOS treats these like sequences. If you start a logical sequence from another sequence, it will be started on the next frame, not executed inline like one might expect from a 'function'.

If Statements

If statements are used to skip events or jump to another place in the sequence based on the evaluation of a logical statement. They might read something like, "If this variable is true, execute the following events. If not, skip them."

'If' events have two variations: (End If) for nesting and (Label) for jumping.


The (End If) variation is used for nesting. Nesting statements begin with the 'If' event and end with the 'End If' event.

An optional 'Else' event can be placed between the 'If' and 'End If'

These are called 'nesting' because it's possible to perform additional 'If' events between any 'If', 'Else', and 'End If' as seen here:


The (Label) variation is used for jumping. These events are a single line, and will jump the sequence to a label if the statement is evaluated as 'True'.

In this example, if the value of the 'count' variable is event the If event will jump to the event labeled 'SKIP EVENS'

Choosing between If, If =, and If Not =


Use the 'If' event to evaluate an expression as true or false.

'If =' / 'If Not ='

Use the 'If =' event to compare two variables or values. If they are equal, the statement will evaluate as True.

The 'If Not =' event is the same as the 'If =' event except reversed. If the values are not equal, the statement will evaluate as True.


The 'Goto' event jumps the sequence execution to a label, skipping any events in-between. This is useful to skip to the end of a sequence, or skip any events that you don't want to execute in the current show state.