Skip to content

Operators ​

There are many different types of Operators that you will use within your Statelake script code.

But what is an Operator?

An Operator is simply a special character, symbol, or keyword that allows the script compiler to perform mathematical or logical equations.

Arithmetic Operators ​

Arithmetic Operators work with numeric data types such as Float and Integer.

Numeric data types can be further manipulated and compared through the use of Relational Operators.

OperatorOperationOperandResultExample
+AdditionFloat, IntegerFloat, Integer1 + 2.06
-SubtractionFloat, IntegerFloat, Integer4 - 3.76
*MultiplicationFloat, IntegerFloat, Integer2.67 * 5
/Float DivisionFloat, IntegerFloat4.5 / 3
divInteger DivisionIntegerInteger10 div 3 (result 3)
modRemainderIntegerInteger10 mod 3 (result 1)

Assignment Operator ​

An Assignment Operator is used to set the value of a variable or parameter.

OperatorOperationOperandResultExample
:=AssignmentAny data typeAny data typeValue := 10;

Boolean Operators ​

Boolean Operators are used within expressions to join multiple conditions. The result of the expression depends on the result of the conditions, and how they are joined.

An example of usage is within an If statement with multiple conditions. Each condition can be joined through the use of a Boolean Operator.

if (Value>10) and (MyVariable=True) returns a True result only if both conditions evaluate to True .

if (Value>10) or (MyVariable=True) returns a True result if only one of the conditions evaluate to True.

if not (Value>10) will result in the test being reversed, and will only evaluate to True if the variable Value is less than 10.

While hardly ever used in a daily situation, xor is widely used however in cryptography, error checking and fault tolerance. Xor compares two input bits and generates one output bit. Where these two bits are the same, then 0 is returned, and where they are not the same, a 1 is returned.

OperatorOperationOperandResultExample
notnegationBooleanBooleanif not (Value > 10) then
andconjunctionBooleanBooleanif (Value>10) and (x=y) then
ordisjunctionBooleanBooleanif (Value>10) or (x=y) then
xorexclusive disjunctionBooleanBooleanif (Value>10) xor (x=y) then

Relational Operators ​

Relational Operators are used to compare the relationship between two data entities, and can compare any data type such as numeric, character string or logical data. The result of the comparison will be either True ( 1 ) or False ( 0 ), and can be used to make a decision regarding program flow.

To compare differing data types using these operators, first convert one data type side so that both sides are the same data type.

When using the less than or greater than operators against String data types, the comparison is performed using alphabetical sorting - abc is less than ade.

OperatorOperationOperandResultExample
=EqualAny Data TypeBooleanif 'abc' = 'abc' then
<>Not EqualAny Data TypeBooleanif 3 <> 4 then
<Less ThanAny Data TypeBooleanif X < Y then
>Greater ThanAny Data TypeBooleanif 3 > 5 then
<=Less than or equalAny Data TypeBooleanif X <= Y then
>=Greater than or equalAny Data TypeBooleanif 5 >= 8 then

String Operators ​

String Operators work with String data types and will add then together to join them into a single string.

Strings can be compared through the use of Relational Operators.

OperatorOperationOperandResultExample
+ConcatenationStringStringValue := 'abc' + 'def';