Expressions

Expressions are a finite combination of functions, variables, constants and mathematical operators that can be evaluated to return a single value. An expression can contain a single function, or can be built up using many.

Expressions are typically used to calculate integer values or produce strings of text that can then be stored in Variables or Properties using Actions, or used in comparison operations in Restrictions. They can also be directly used in output text by using Embedded Expressions.

Expressions are the closest ADRIFT comes to "programming". They can often provide a more efficient way of calculating values than using restrictions and actions alone. For example, say you were implementing a time system which had hours and minutes. Every time Minute reached 60 you would want to reset it to 0 and increment Hour.

One way of doing this would be to have a task that incremented Minute by 5. It would need to have a restriction that Minute was < 55. You would need a second task that had a restriction that Minute was = 55, and if so this would set Minute back to 0 and run another task to increment Hour. You would then need to add checks on the increment Hour task to make sure it didn't go past 23. This is getting complicated with lots of tasks.

Another way of doing this would be so have a single task "increment time" which sets Hour to the following expression:

And then set Minute to the following:

- Expressions may contain Item Functions, General Functions, Expression Functions, variables, constants (string constants must be surrounded by double quotes) and References.
- Numeric operators (+, -, *, /, ^, mod) can be used when the expression being evaluated result in numeric operands.
- String operators (&) can be used to concatenate text values.
- Normal brackets can be used to determine the order of evaluation.
- Logical operators (AND, OR) can be used when comparing two test values.
- Relationship operators (>, >=, =, <=, <, !=) can be used to compare numeric values.

Expression Functions

For a full list of functions supported in expressions, see Expression Functions.

An expression can also be embedded into any piece of text within a text box by placing it between the symbols <# and #>.

For example, you could embed the OneOf function into a piece of text to give a random response to a question like so:

Or you could have a description in a Casino like so: