Expressions

An expression is a sequence of operands and operators that are evaluated to return a value. Operators indicate the type of procedure to perform on the operands. The operands are usually items in the application dictionary, such as the content of fields or the values returned from functions or other expressions. In sanScript, there are four kinds of expressions: numeric, date and time, string, and boolean.

Numeric expressions

Evaluating a numeric expression results in numeric value. For instance, the following sanScript statement uses a numeric expression that returns the total price of a sale by adding the subtotal and sales tax fields.

```'Total' = 'Subtotal' + 'Tax';

```

The following table lists the numeric operators in the order they’re evaluated.

Operator

Use

Example

unary minus (-)

negation

-15

^

power

10^3

*, /,%

multiplication, division and modulus

15/3

+,-

5+10

<<, >>, shiftl, shiftr

shift operations

4>>2

=,<>,<,>,<=,>=

comparison

4 >= 2

Date and time expressions

Evaluating a date and time expression results in a date, time or a numeric value. For instance, the following sanScript statement adds 30 days to the value of the Todays Date field to set the Due Date for a payment.

```'Due Date' = 'Todays Date' + 30;

```

The following table lists the date and time operators in the order they’re evaluated.

Operator

Use

Example

+,-

sysdate() + 30

=,<>,<,>,<=,>=

comparison

sysdate() <= 'Due Date'

 When comparing time values, be aware that the seconds portion of the time value is ignored.

String expressions

Evaluating a string expression results in a string value. For instance, the following sanScript statement joins two string values and stores the result in the Name field.

```Name = "Cindy " + "Johnson";

```

The following table lists the string operators in the order they’re evaluated.

Operator

Use

Example

+

concatenation

"Sara " + "Johnson"

=,<>,<,>,<=,>=

comparison

'Name' <> "Smith"

Boolean expressions

Evaluating a boolean expression results in boolean value of true or false. Boolean expressions are used in decision-making statements such as the if then...end if statement. For instance, the following sanScript statement evaluates the boolean expression in the if then...end if statement to determine whether the value of the Number of Users field is greater than 5.

```if 'Number of Users' > 5 then
warning "There are too many users in the system.";
end if;

```

The following table lists the boolean operators in the order they’re evaluated.

Operator

Use

Example

not

logical not

not (err() = 0)

=,<>

equal, not equal

(6 + 4) = (5 + 5)

and

logical and

(Amount > 10) and (Amount < 20)

or

logical or