Introduction

The following article outlines the operators and function available to you via admScript in SchemeServe. For more practical examples relating to Documents or Reports, see the topics advanced documents or advanced reports.

Arithmetic

In admScript you'll find the standard arithmetic operators like + and - but also modulo (%) and power (^).

Example: x * 2 + y ^ 2 - 100 % 4

Comparison

We have included the usual comparison operators, including the equal operator = and the not equal operator <>.

Example: x <> 100

And/Or/Xor/Not

admScript will use these operators for logical and bitwise operations. Since the admScript language is strongly-typed, it determines the types of operands to these operators. If both are booleans, the operation is deemed logical. If both are integral, the operation is deemed bitwise. The use of alternative combinations will fail by design.

Logical example: x > 100 AND NOT y = 100
Bitwise example: (100 or 2) AND 1

Concatenation

The + operator is also used for string concatenation. If either of its operands is a string, the + operator will concatenate instead of performing addition.

Example: "abc" + "def"
Example: "the number is: " + 100

Indexing

The admScript indexing operator looks like this: member[indexExpression]. If you try to index a variable which is not a valid array the expression will fail.

Example: arr[i + 1] + 100

Literals

admScript supports the following literals in expressions:

Char - A character in single quotes: 'a'

Boolean - Either true or false

Real - Any number with a decimal point. You can use the 'd', 'f', or 'm' suffixes to specify whether the number should be stored in a double, single, or decimal respectively. Use the ExpressionOptions.RealLiteralDataType option to specify the data type used to store the number when no suffix is specified. The default is double.

Integral - Any number without a decimal point. Append "L" to force the number to a 64-bit integer and/or a "U" to force it to unsigned. admScript will try to assign an integer literal to the first integral type that can contain the value.

String - String literals are enclosed in double quotes and escaping characters follows the same rules as C#: "string\u0021\r\n a \"new\" line"

Null - Using the keyword null will load the null reference into an expression.

Casting

Casting can optionally be performed using a special function, cast, which looks like this: cast(value, type).

Example: 100 + cast(obj, int)

The Conditional Operator IF

admScript includes a conditional operator, IF, which allows you to pick a result based on a boolean test or condition. It looks like this: if(condition, whenTrue, whenFalse). Only the expression that matches the condition is evaluated.

Example: IF(a > 100 and b > 10, "both greater", "less")

The In Operator

The In operator is a boolean binary operator that returns true if its first operand is contained in its second operand. It has two forms:

List: Searches a list of values for a given value: value IN (value1, value2, value3,...). The value is compared against each value in the list and true is returned if the value is found, false if no match is found.

Collection: Searches a single collection for a given value: value IN collection.

Example (List): If(100 in (100, 200, 300, -1), "in", "not in")
Example (Collection): if(100 in collection, "in", "not in")