In parsing an expression, the longest legal expression is used. This permits coordinates to be specified by several consecutive expressions with no special separators.
is_defined(stringexpr)The stringexpr must be a quoted string or other string expression. The return value is 0 if the name is undefined, 1 if defined. This function is evaluated at parse-time, not run-time, so a command like if is_defined(newvar) then newvar := 1 else newvar := 0 will give newvar the value 0 if this is its first appearance.
2 -3 .5 23. 5e-10 +0.7D2Hexadecimal integers starting with Ox, as in 0x12Af, are also accepted. Color names are interpreted as integers.
-1 CLEAR 0 BLACK 1 BLUE 2 GREEN 3 CYAN 4 RED |
5 MAGENTA 6 BROWN 7 LIGHTGRAY 8 DARKGRAY 9 LIGHTBLUE 10 LIGHTGREEN |
11 LIGHTCYAN 12 LIGHTRED 13 LIGHTMAGENTA 14 YELLOW 15 WHITE |
==,>,<,>=,<=,!= | Numerical or boolean comparison. |
NOT, ! | Boolean NOT |
AND, && | Boolean AND, with short-circuit evaluation. |
OR, || | Boolean OR, with short-circuit evaluation. |
Operator | Associativity |
---|---|
^,** | left associative |
unary - | right associative |
*,/,%,IMOD,IDIV | left associative |
+,- | left associative |
on_boundary | nonassociative |
on_constraint | nonassociative |
hit_constraint | nonassociative |
==,>,<,>=,<=,!= | right associative |
NOT, ! | right associative |
AND, && | left associative |
OR, || | left associative |
? : | left associative |
= | left associative |
SIZEOF(name)where name is the name of the extra attribute, not in quotes.
is_defined
To find out if a name is already in use as a keyword or
user-defined name, use the is_defined function, which
has the syntax
is_defined(stringexpr)The stringexpr must be a quoted string or other string expression. The return value is 0 if the name is undefined, 1 if defined.
aggregate(generator,expr)where aggregate is max, min, sum, or avg, and generator is an element generator. Example: this prints the total area of all green facets:
print sum(facet where color == green, area)"Count" is an aggregate function that gives the number of elements generated, regardless of the expression.
foreach facet do print areaOtherwise the attribute is referred to as a field of the element:
foreach facet ff do print ff.areaIndexed extra attributes need an index in square brackets:
foreach facet ff do print ff.something[3]Index values are rounded down to integer values. Indexing starts with 1.
Most attributes are numerical or boolean, but some are element generators.
The following attributes are available (for details, see elements):