Skip to content

Expressions

Expressions are used throughout WinScript to perform logical analysis, triggers, and mathematical operations. Expressions cannot be used for string comparison at this time. String comparison must be performed in a logical sequence using the If = and If Not = events

Logic

Logical analysis is performed in conjunction with the If, Else If, Else, and End If events. When an expression for an If event is true, all events located after it and before an Else, Else If, or End If event will be executed. The events located after an Else If condition will be executed if the prior conditions were false and the Else If condition is true. The events located between the Else and End If events will be executed if all prior conditions were false.

Here's an example using just If and End If events:

Here's an example of If, Else If, Else, and End If being used together:

When adding events to a Timed sequence, expressions can be used in the Condition column of each event. If an expression is associated with a timed event, that event will only execute if the expression evaluates true.

Note

Conditions in timed sequences will be evaluated one Pre-Roll period before the event should take effect, to allow time for events to be scheduled and messages to be sent.

Triggers

Expressions can also be used to trigger sequences. In this case, expressions are constantly analyzed and if they ever become TRUE, the trigger will occur.

Math

Mathematical operations are also possible thanks to expressions. Various operators and functions (listed below) can be used to make calculations to any constant or variable values you enter into the expression formula.

Variables

Up to 8 variable names can be used within an expression. Each variable is converted to a Decimal value before evaluating the expression. String variables and string constants cannot be used in expressions.

Important Note: Variable names that contain operators such as '-' must be wrapped in backtick marks. For example, given the follow variables and values, choosing to not use backticks changes the meaning of the expression.

Name Value
taco 5
tuesday 2
taco-tuesday 7

With backticks "`taco-tuesday`+1" = 8

Without backticks "taco-tuesday+1" = 4

Values

Explicit values (literals) can also be used in an expression. For example, using true or false for boolean comparisons.

Booleans, Integers, Decimals, Percents, and Timecode values are supported. Strings are not supported.

When using timecode literals in an expression, the system framerate is used by default. However, if the expression contains a timecode variable, then the timecode variable's framerate will be used. Expressions support partial or full timecode values; as long as there is a colon as a timecode delimiter, the expression will interpret it as a timecode value. Timecode values are evaluated as fractional seconds by default, unless the toframes function is used.

Expression Operators

These are the supported operators for Boolean logic:

Operator Description
! NOT
< Less Than
<= Less Than or Equal To
> Greater Than
>= Greater Than or Equal To
== Equal To
!= NOT Equal To
&& AND
|| OR

Supported Operators:

Operator Description
+ Add
- Subtract
* Multiply
/ Divide
% Modulo
^ Power
() Parentheses
`` Backtick

Expression Functions

Supported Functions:

Function Description
cos(x) cosine of a radian angle x
cosh(x) hyperbolic cosine of x
acos(x) arc cosine of x in radians
sin(x) sine of a radian angle x
sinh(x) hyperbolic cosine of x
asin(x) arc sine of x in radians
tan(x) tangent of a radian angle x
tanh(x) hyperbolic tangent of x atan(x) arc tangent of x in radians
atan2(y,x) arc tangent in radians of y/x based on the signs of both values to determine the correct quadrant
abs(x) absolute value of x
ceil(x) rounds up x to a whole number
floor(x) rounds down x to a whole number
ln(x) natural log of x (base-e)
log(x) log of x (base-10)
ncr(n,r) number of unordered set of r items from a set of n items. (combinations)
npr(n,r) number of ordered set of r items from a total of n items (permutations)
pow(x,y) x to the y power
exp(y) e to the y power
fac(x) factorial of x
sqrt(x) square root of x
pi() Pi Constant - 3.14159...
e() Euler's Number Constant - 2.71828...
toframes(x,y) frame count of timecode x at y framerate
totime(x,y) decimal value of timecode x at y framerate