Operators

What is an Operator?

An operator is a symbol that tells the system to perform a specific logical or mathematical action and produce a final result. An example of an operator is the plus sign (+), which is used to tell the system to add 2 numbers together.

In programming, operators are not just used for mathematical operations. They can also be used to perform logical, comparison, and assignment actions which are described below.

For example, the plus sign (+) operator can also be used to combine 2 strings into one larger string. Other examples of different functions operators can perform include comparing 2 Booleans to see if they match, or even assigning a value into a new variable.

There are 5 main types of operators used with UiPath:

Arithmetic Operators

Arithmetic operators are mathematical actions used to perform calculations on two or more sets of data. For example, we can program the robot to perform a simple calculation like adding two numbers together (2 + 3).

Arithmetic operators only work with numerical data types, such as integers (Int32), doubles, and floats. 

In the examples below, assume variable A holds an integer of 2 and variable B holds an integer of 7.

Operator Description Example (A=2,B=7) Return Type
  ^
To the Power of
B^A returns 49
Integer
  +
Adds
A + B returns 9
Integer
  -
Subtracts
A - B returns -9
Integer
  *
Mutiplies
A * B returns 14
Integer
  /
Divides (Returns Float)
B / A returns 3.5
Float
  \
Divides (Returns Integer)
B \ A returns 3
Integer
  MOD
Remainder
B MOD A returns 1
Integer

Comparison Operators

Comparison operators are actions used to perform comparisons between two or more sets of data and return a value of true or false depending on the results of the comparison. 

These are typically used for numerical data types, such as integers (Int32), doubles, and floats. Performing actions with Comparison Operators will return a Boolean value of either True or False. 

In the examples below, assume variable A holds an integer of 2 and variable B holds an integer of 7. 

Operator Description Example (A=2,B=7) Return Type
  =
Equals
A = B returns False
Boolean
 
Does Not Equal
A B returns True
Boolean
  >
Greater Than
A > B returns False
Boolean
  <
Less Than
A < B returns True
Boolean
  >=
Greater Than or Equal To
A >= B returns False
Boolean
  <=
Less Than or Equal To
A <= B returns True
Boolean

String Operators

String Operators are actions used to perform comparisons between two or more strings and return a Boolean value of true or false depending on the results of the comparison. 

These can only be used to compare String data types. 

In the examples below, assume variable A holds a string of “DOG” and variable B holds a string of “CAT”.

Operator Description Example (A=DOG, B=CAT) Return Type
  Is
Is Equal To
A Is B returns False
Boolean
  IsNot
Does Not Equal
A IsNot B returns True
Boolean
  Like
Is Like
A Like B returns False
Boolean

Logical Operators

Logical Operators are used to combine two or more expressions so that the combined expression can be calculated and a Boolean result of true or false returned. 

This allows a program to make a decision based on multiple conditions. Logical operators can also be used with most data types, not just numbers.

In the examples below, assume variable A holds a Boolean of True and variable B holds a Boolean of False.

Operator Description Example (A=True, B=False) Return Type
  And
Both operands must be True
A And B returns False
Boolean
  Or
Any of the operands must be True
A Or B returns True
Boolean
  Not
Reverses logical state of operand
Not(A And B) returns True
Boolean
  Xor
Only 1 Or condition can be met
A Xor B returns True
Boolean
  AndAlso
Logical And Operator (Boolean Only)
A AndAlso B returns False
Boolean
  OrElse
Logical Or Operator (Boolean Only)
A OrElse B returns True
Boolean
  IsFalse
Determines if expression is False
C IsFalse returns False
Boolean
  IsTrue
Determines if expression is True
C IsTrue returns True
Boolean

Assignment Operators

Assignment Operators are used to assign values to variables. 

As UiPath has the Assign and Multiple Assign activities which are extremely powerful and discussed here, these operators do not need to be used unless invoking your own VB.Net code.

Operator Description Example Return Type
  =
Assigns value from right side to left
C=A+B will assign C
Depends on Input
  +=
Adds and assigns to left operand
B+=A is like B=B+A
Depends on Input
  -=
Subtracts and assigns to left operand
B-=A is like B=B-A
Depends on Input
  *=
Multiplies and assigns to left operand
B*=A is like B=B*A
Depends on Input
  /=
Divides and assigns to left operand
B/=A is like B=B/A
Depends on Input
  \=
Divides and assigns to left operand
B\=A is like B=B\A
Depends on Input
  ^=
Exponentiate and assigns to left operand
B^=A is like B=B^A
Depends on Input
  &=
Concatenates strings and assigns result
A&=B is like A=A&B
Depends on Input