Each clause begins with an operator that is recognized by the script engine. Current possibilities are listed below:
Operator & Args | Purpose | Explanation |
---|---|---|
+ [a] ... [n] | Add | 2 or more arguments, each of which must be a number |
- [a] ... [n] | Subtract | 2 or more arguments, each of which must be a number |
* [a] ... [n] | Multiply | 2 or more arguments, each of which must be a number |
/ [a] ... [n] | Divide | 2 or more arguments, each of which must be a number |
eq [a] [b] | Equality | 2 arguments, each of which must be a number. Returns true if they are numerically equivalent. |
lt [a] [b] | Less-Than | 2 arguments, each of which must be a number. Returns true if [a] is less than [b]. |
gt [a] [b] | Greater-Than | 2 arguments, each of which must be a number. Returns true if [a] is greater than [b]. |
le [a] [b] | Less-Equal | 2 arguments, each of which must be a number. Returns true if [a] is less than or equal to [b]. |
ge [a] [b] | Greater-Equal | 2 arguments, each of which must be a number. Returns true if [a] is greater than or equal to [b]. |
! [arg] | Not | 1 argument. Returns true if [arg] is false. |
seq [a] [b] | String-Equal | 2 arguments, each of which must be a string. Returns true if [a] is equal to [b]. |
sstr [a] [b] | Is-SubString | 2 arguments, each of which must be a string. Returns true if and only if [a] contains the string [b]. |
? [test] [t] [f] | Conditional | 3 arguments. If the first, [test], is true (non-zero) returns the result contained in [t]. Otherwise, returns the result in [f]. |
br [b] [res-0] ...[res-n] | Branch | 2 or more arguments. The first, [b], must be an integer, the remaining elements are treated as a list indexed from 0 to n. If [b] <= 0, returns the result contained in [res-0]. If [b] >= n where n is the index of the last argument, returns [res-n]. Otherwise, returns the [b]th element in the list of results. |
all [a] ... [n] | Do All | 1 or more arguments. Evaluate each argument and return the result of the last one. |
or [a] ... [n] | Logical Or | 1 or more arguments. Returns 1 if one or more arguments evaluates to true. Returns 0 otherwise. |
and [a] ... [n] | Logical And | 1 or more arguments. Returns 1 if all arguments evaluate to true. Returns 0 otherwise. |
rand | Random Number | 0 arguments. This function generates a random integer greater than zero. |
int [a] | TCast to Int | 1 argument. Casts the argument as an integer value. Limited support, but it works for dates and times. |
dur [a] | Cast to Dur | 1 argument. Casts the argument as a duration. Currently, this only works for integer type fields. The integer value will be interpreted as the number of minutes since midnight January 1, 1904, and displayed as the number of days, hours and minutes since then. |
Example:
Here are some uses:
(+ %0 %1)
add fields 0 and 1 together
(+ %0 (* %1 4))
add field 0 to 4*(field 1)
(? (eq %0 10) 100 -100)
if field 0 equals 10, return 100, else return -100
(all 5)
just return the constant 5