Syntax
As its name suggests, everything in the expression language is an "expression". This means that everything returns a value. 5 is an expression. So is 5+1. So are {MyTags/TankLevel} and and {MyTags/TankLevel}+1. Expressions can be combined in many powerful ways. Lets take a look at how expressions are written.
More formally, an expression is any one of the following:
 Number
 Boolean
 String
 Bound tagTag
 Bound property
 Function call
 Dataset access
 Equation involving any of these
Literal Values
Literal values are things like numbers, booleans, and strings that are represented directly in the language. In the expression language, numbers can by typed in directly as integers, floating point values, or using hexadecimal notation with a 0x prefix. Examples:
Code Block 


42
8.456
0xFFC2 
Strings are represented by surrounding them with double or single quotes. You can use the backslash character to escape quotes that you want to be included in the string. Examples:
Code Block 


"This is a regular string"
'This one uses single quotes'
"This string uses \"escaping\" to include quotes inside the string" 
Operators
You can use these arithmetic, logical, and bitshifting operators to combine expressions.
OperatorNameDescription//CommentsAllows for comments following this operator.Unary Minus or SubtractionIf both preceeded by a number, then returns the of subtracting the operand right from the operand on the left of the operator:
If preceded by anything else (or nothing, such as the start of the expression) and is followed by a number, this operator will negate the numberIn addition, the following escape characters are available:
Character  Description 

\n  New line 
\r  Tab 
\t  Carriage return 
Code Block 


// The words "Hello" and "User" will be placed on separate lines
"Hello\nUser"
// Each "\t" will inject a tab
"Lots\tOf\tSpace" 
Operators
You can use these arithmetic, logical, and bitshifting operators to combine expressions.
Operator  Name  Description 

//  Comments  Allows for comments following this operator. 
  Unary Minus or Subtraction  If both preceeded by a number, then returns a value by subtracting the operand right from the operand on the left of the operator: If preceded by anything else (or nothing, such as the start of the expression) and is followed by a number, this operator will negate the number. Code Block 

 // This will return 6
10  4
// This will return 10
 (15  5) 

!  Not  Logical opposite of a boolean. 
^  Power  Raises a number to the power of another number. 
%  Modulus  Modulus or remainder of two numbers. a%b is the remainder of a÷b. 
*  Multiply  Multiplies the number on the left of the operator by the number on the right of the operator. 
/  Divide  Divides the number on the left of the operator by the number on the right of the operator. 
+  Add or Concatenation  If both operands are numbers, this will add them together. Otherwise treats arguments as strings and performs concatenation. Code Block 

 // This will return 10
4 + 6 

10  4
// This will return 'FirstSecond'
'First' + 'Second'
// This will return 

10
 (15  5)!Not
Logical opposite of a boolean.^PowerRaises a number to the power of another number. %ModulusModulus or remainder of two numbers. a%b is the remainder of a÷b.*MultiplyMultiplies the number on the left of the operator by the number on the right of the operator./DivideDivides the number on the left of the operator by the number on the right of the operator. +Add/ConcatonateIf both operands are numbers, this will add them together.
Otherwise treats arguments as strings and performs concatenation. 
  Subtraction  Subtracts the number on the right of the operator from the number on the left of the operator. 
~  Bitwise NOT  Examples the bits of an operand, and performs performs logical negation: bits with a value of 0 become 1, and vice versa. 
&  Bitwise AND  Examines the bits of two operands, and performs a logical AND to each set, comparing the bits in each position from both sets. Returns true for any position where the bits being compared are true. Code Block 

 // 0101
// AND 0011
// = 0001
// Performs the bitwise operation above, resulting in the decimal 1
5 & 3 

  Bitwise OR  Examines the bits of two operands, and performs a logical OR to each set, comparing the bits in each position from both sets. Returns true for any position where either bit being compared is true. 
// This will return 10
4 + 6// 0101
// OR 0011
// = 0111
// 

Thiswillreturn 'FirstSecond'
'First' + 'Second'
// This will return '2Alarms'
2 + 'Alarms'SubtractionSubtracts the number on the right of the operator from the number on the left of the operator. &Bitwise ANDbitwise operation above, resulting in the decimal 7
5  3 

xor  Bitwise XOR  
both two operands, and performs a logical 
AND to each pair of bitsexclusive OR to each set, comparing the bits in each position from both sets. Returns true for any position where only one of the bits are true. 
AND 00010110
// Performs the bitwise operation above, resulting in the decimal 

1&Bitwise OR xorBitwise XOR 
<<  Left Shift  A signed bitwise left shift. 
>>  Right Shift  A signed bitwise right shift. 
>  Greater Than  Logical greaterthan test between two numbers. Returns a boolean. 
<  Less Than  Logical lessthan test between two numbers. Returns a boolean. 
>=  Greater Than or Equal To  Tests if the operand on the left is greater or equal to the operand on the right. Returns a boolean. 
<=  Less Than or Equal To  Tests if the operand on the left is less than or equal to the operand on the right. Returns a boolean. 
=  Equal  Tests for equality between two operands. 
!=  Not Equal  Tests for equality, returning true when not equal. 
&&  Logical AND  Returns true when both operands are true. Anything nonzero is considered true. 
  Logical OR  Returns true when either operand is true. Anything nonzero is considered true. 
like  Fuzzy String Matching  Compares the lefthand value with the pattern on the right side. The pattern may consist of %,*, and ? wildcards. 
Bound Values
Bound values are paths to other values enclosed in braces. These will appear red in the expression editor. When you are writing an expression for a Expression Binding in Vision, you can reference tag Tag values and property values using the brace notation. When you are writing an expression for an Expression Tag, you can only reference other tag Tag values. You can use the Insert Property ( Image Removed ) Property Image Addedicon and Insert Tag Value ( Image Removed ) buttons Image Added icon to build these references for you.
Dataset Access
If you have an expression that returns a dataset, you can pull a value out of the datatset using the dataset access notation, which takes one of these forms:
Code Block 


Dataset_Expression ["Column_Name"] //returns the value from the first row at the given column name
Dataset_Expression [Column_Index] //returns the value from the given column at the first row
Dataset_Expression [Row_Index, "Column_Name"] //returns the value from the given row at the given column name
Dataset_Expression [Row_Index, Column_Index] //returns the value from the given row at the given column index 
For example, this expression would pull a value out of a Table at row 6 for column "ProductCode":
Code Block 


{Root Container.Table.data}[6, "ProductCode"] 
Note that you'll often have to convince the expression system that what you're doing is safe. The expression language can't tell what the datatype will be for a given column, so you may have to use a typecasting function to convince the expression language to accept your expression, like this:
Code Block 


toInt({Root Container.Table.data}[6, "ProductCode"]) 
Expression Functions
The expression language's functions are where much of the real power lies. A function may take various arguments, all of which can themselves be any arbitrary expression. This means that you can use the results of one function as the argument to another function. In general, the syntax for a function call is:
Code Block 


functionName(expression1, expression2, ...) 
Whitespace, such as spaces, tabs and newlines, are largely ignored in the expression language. It is often helpful to break your expression up onto multiple lines for clarity. Comments are delimited by two forward slashes. This will make the rest of that line be ignored. This example shows an if function spread over 4 lines with comments annotating the arguments.
Code Block 


if( {Root Container.UseTagValueOption.selected},
{MyTags/SomeValue}, // Use the tag value
"Not Selected" // Use default value if the user doesn't check the box
) value if the user doesn't check the box
) 
Tag Paths
While referencing a tag path in expressions, you may see some special notation, such as "~" and "[.]". More information on this notation can be found on the Understanding Tags page.