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 run-time, but variables in the whole command are parsed before the command is executed, so a command like if is_defined("newvar") then newvar := 1 else newvar := 2 will give newvar the value 1 even if this is its first appearance. A better way in scripts to test is to use the define command to define the variable without initialization, and then test to see if it has the default value, i.e. 0 for a numeric variable and a sizeof 0 for a string variable.
2 -3 .5 23. 5e-10 +0.7D2Hexadecimal integers starting with 0x, as in 0x12Af, are also accepted, as are binary numbers such as 11001b, indicated by a trailing 'b'. 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
on_constraint hit_constraint on_quantity on_method_instance | nonassociative |
==,>,<,>=,<=,!= | right associative |
NOT, ! | right associative |
AND, && | left associative |
OR, || | left associative |
? : | left associative |
= | left associative |
SIZEOF(name) SIZEOF(string)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. This function is evaluated at run-time, but variables in the whole command are parsed before the command is executed, so a command like if is_defined("newvar") then newvar := 1 else newvar := 2 will give newvar the value 1 even if this is its first appearance. A better way in scripts to test is to use the define command to define the variable without initialization, and then test to see if it has the default value, i.e. 0 for a numeric variable and a sizeof 0 for a string variable.
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):
DEFINE variablename REAL|INTEGER [expr]...This syntax works both in the datafile header and at the command prompt. If the array already exists, it will be resized, with old elements kept as far as possible. Do not resize with a different number of dimensions. Note that array indexing starts at 1. A size of 0 is legal, and useful if you are not using an array at the moment and want to free storage space. There is runtime checking of array bounds. Example:
define fvalues integer[10][4] define basecoord real[10][space_dimension]Array elements may be used and assigned as is usual for programming languages:
fvalues[3][4] := 234; if basecoord[3][1] > 2 then print "hello world!\n";The print command may be used to print whole arrays or array slices in bracketed form. Example:
print fvalues print fvalues[4]