Skip to content

Expressions

Expressions are used throughout WinScript to perform logical analysis, triggers, and mathematical operations.

Logic

Logical analysis is performed in conjunction with the If, Else, and End If events. When an expression is used with an If event, all events located after the If event and before an Else or End If event will be executed if the expression evaluates as TRUE. If the expression evaluates as FALSE, any events located between the Else and End If events will be executed. If there is no Else event, the sequence will simply skip to the End If event.

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

Here's an example of 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 as TRUE.

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.

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

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...