The rule language: notation, references, operators — gull system handbook
Syntax of the gull system rule language: numbers, text, booleans, references to inputs and tables, operators and their precedence, error values.
The rule language: notation, references, operators
Formulas as in Excel: numbers with a point, text in quotes, names in square brackets, functions in capitals. The same holds in rules, variables, form fields and folder names.
Values
- Kind: number - Notation: `12`, `0.5`, `.5` - Note: a decimal point; `1,5` is two arguments. No units, no `1e3`.
- Kind: text - Notation: `"Stainless"` - Note: a quote inside text is doubled: `"""A"""`
- Kind: boolean - Notation: `TRUE`, `FALSE` - Note: case does not matter; `TRUE()` works too
- Kind: list - Notation: `"A|B|C"` - Note: text with pipe-separated items; read by the LIST… functions
- Kind: inline table - Notation: `{"h1","h2";"v1","v2"}` - Note: comma separates columns, semicolon rows, the first row is the header
A leading `=` is optional. An empty argument is allowed: `TABLECOLUMNLOOKUP(x, a, b, , "NEAREST")`.
References
- A name of letters, digits and `_` starting with a letter can stand bare: `Length * 2`. Anything else — a space, a hyphen — goes in square brackets: `[Bed length]`. Whatever is in brackets is always a reference, so `[TRUE]` is an input named TRUE.
- Case is ignored for names and functions alike.
- A Library table is referred to by its name: `VLOOKUP([Width], Sizes, 3, FALSE)`. Every table function also takes the name as text.
- One namespace, in this order. input → a Steps element's name in the form → variable → constant → table. The same name in two places is refused, see Name things so that they connect.
Operators, loosest first
- Operator: `AND`, `OR` - Meaning: logical and / or - Note: one kind per chain: `a AND b OR c` is refused without brackets
- Operator: `=` `==` `<>` `!=` `<` `>` `<=` `>=` - Meaning: comparison - Note: two numbers numerically, otherwise as text regardless of case; `a < b < c` is an error
- Operator: `&` - Meaning: text join - Note: looser than `+`, as in Excel
- Operator: `+` `-` - Meaning: add, subtract - Note:
- Operator: `*` `/` - Meaning: multiply, divide - Note: division by zero gives `#NUM!`
- Operator: `^` - Meaning: power - Note: left to right: `2^3^2` is 64
- Operator: `-x`, `+x` - Meaning: sign - Note: tighter than `^`: `-2^2` is 4
- Operator: `x%` - Meaning: percent - Note: divides by a hundred
- Operator: `( )` - Meaning: brackets - Note:
Conversions
- Text that is not a number gives `#VALUE!` in arithmetic. Empty text is never read as 0.
- A non-zero number and non-empty text count as true.
- A boolean is written into text as `1` or `0`.
Error values
- Value: `#VALUE!` - When: wrong type, wrong argument count, lookup value not found, a table used as one value
- Value: `#NAME?` - When: unknown name or function
- Value: `#NUM!` - When: division by zero, square root of a negative, a power that cannot be computed
- Value: `#REF!` - When: an index outside the table
- Value: `#NA!` - When: `LISTFINDITEM` found nothing
- Value: `#CIRCULAR!` - When: a variable that depends on itself
An error passes through every operator and function; only `IFERROR`, `ISERROR`, `ISNUMBER`, `ISTEXT` and `ISEMPTY` stop it. A syntax error is refused at once and a rule with one is not saved. How to read errors is in Error values #VALUE!, #NAME? and the rest.