Alchemy builds on a limited subset of the SQL syntax. All statements are case-insensitive. This section describes the operators (arithmetic, boolean and ternary) available for use in a Alchemy script and the order of precedence when using multiple expressions.
Alchemy uses standard C-style comments:
/* This is a comment */
Arguments may be passed to an Alchemy script from the command line. These arguments may be referenced from inside your Alchemy script using the $args array:
PRINT "This script file located at: " + $args; PRINT "This script file was given " + length($args) + " arguments.";
The $args array is equivalent to the argv array in C. The first argument is the path to the Alchemy script, the remaining arguments are those passed to the script from the command line.
1 + 1 = 2
3 - 1 = 2
2 * 1 = 2
Division: 4 / 2 = 2
system.io.path.combine: "C:\temp" / "data.dbf" produces "C:\temp\data.dbf"
Modulo: Remainder operator
5 % 3 = 2
Example that returns true
Logical Or: true if one or both of its arguments are true
true OR false
true OR true
Logical And: true if both of its arguments are true
true AND true
Logical Not: true if its argument is false
Logical In: true if its left argument is included amongst its right arguments
"A" IN ("A", "B", "C")
Less Than: true if its left argument is smaller than its right argument
1 < 2
Greater Than: true if its left argument is larger than its right argument
2 > 1
Less Than Or Equal To: true if its left argument is the same size or smaller than its right argument
1 <= 2
2 <= 2
Greater Than Or Equal To: true if its left argument is the same size or larger than its right argument
2 >= 1
2 >= 2
Equal To: returns true if both of its arguments are identical
1 * 5 = 5
(1 + 2) == (4 - 1)
Not Equal To: returns true if its arguments are not identical
(1 + 1) != 3
"left" <> "right"
expr ? result_true : result_false;
The logical expression, expr, is evaluated. If expr is true then result_true is performed. Otherwise, if expr is false, result_false is performed.
result_true and result_false can be any data type or even separate logic expressions.
The function of the ternary operator in Alchemy is identical to its functionality in C.
Operators are executed according to their value in the following precedence table: operators with the lowest value will be executed first, while operators with the highest value will be executed last. If an expression contains two or more operators with the same order of execution the rightmost operation in the expression will be executed first.
* / %
< > <= >= != <> = == IN
Order of Execution