Cube-it 16.3 User Documentation
The rules that APREPRO uses when identifying functions, variables, numbers, operators, delimiters, and expressions are described below:
Function names are sequences of letters and digits and underscores (_) that begin with a letter. The function's arguments are enclosed in parentheses. For example, in the line atan2(a,1.0), atan2 is the function name, and a and 1.0 are the arguments. See APREPRO Functions for a list of the available functions and their arguments.
A variable is a name that references a numeric or string value. A variable is defined by giving it a name and assigning it a value. For example, the expression a = 1.0 defines the variable a with the numeric value 1.0; the expression b= "A string" defines the variable b with the value "A string". Variable names are sequences of letters, digits, and underscores (_) that begin with either a letter or an underscore. Variable names cannot match any function name and they are case-sensitive, that is, abc_de and AbC_dE are two distinct variable names. A few variables are predefined, these are listed in APREPRO Predefined Variables. Any variable that is not defined is equal to 0. A warning message is output to the terminal if an undefined variable is used, or if a previously defined variable is redefined. To see a list of all of the current APREPRO variables use the DUMP() command.
Numbers can be integers like 1234, decimal numbers like 1.234, or in scientific notation like 1.234E-26. All numbers are stored internally as floating point numbers.
Strings are sequences of numbers, characters, and symbols that are delimited by either single quotes ('this is a string') or double quotes ("this is another string"). Strings that are delimited by one type of quote can include the other type of quote. For example, {'This is a valid "string"'}. Strings delimited by single quotes can span multiple lines; strings delimited by double quotes must terminate on a single line or a parsing error message will be issued.
Operators are any of the symbols defined in APREPRO Operators. Examples are + (addition), - (subtraction), * (multiplication), / (division), = (assignment), and ^ (exponentiation).
The delimiters recognized by APREPRO are: the comma (,) which separates arguments in function lists, the left curly brace ({) which begins an expression, the right curly brace (}) which ends an expression, the left parenthesis ( which begins a function argument list, the right parenthesis ) which ends a function argument list, the single quote (') which delimits a multi-line string, and the double quote (") which delimits a single-line string.
An expression consists of any combination of numeric and string constants, variables, operators, and functions. Four types of expressions are recognized in APREPRO: algebraic, string, relational, and conditional.
Almost any valid FORTRAN or C algebraic expression can be recognized and evaluated by APREPRO. An expression of the form a=b+10/37.5 will evaluate the expression on the right-hand-side of the equals sign and assign the value to the variable a. An expression of the form b+10/37.5 will simply evaluate the expression. Variables can also be set on the command line prior to playing any journal files using the 'var=val' syntax. Only a single expression is allowed within the { } delimiters. For example, {x = sqrt(y^2 + sin(z))}, {x=y=z}, and {x=y} {a=z} are valid expressions, but {x=y a=z} is invalid because it contains two expressions within a single set of delimiters.
APREPRO has very limited string support. The only supported operations are assigning a variable equal to a string (a = "This is a string") or a function that returns a string, and concatenating two strings into another string (a = "Hello" // " " // "World").
Relational expressions are expressions that return the result of comparing two expressions. A relational expression is either true or false. Relational expressions can only be used on the left-hand side of a conditional expression. A relational expression is simply two expressions of any kind separated by a relational operator. See Relational Operators.
APREPRO recognizes a conditional expression of the form::
relational_expression ? true_exp : false_exp
where relational_expression can be any valid relational expression, and true_exp and false_exp are two algebraic expressions. If the relational expression is true, then the result of true_exp is returned, otherwise the result of false_exp is returned. For example, if the following command were entered:
#{a = (sind(20.0) > cosd(20.0) ? 1 : -1)}
then, a would be assigned the value -1 since the relational expression to the left of the question mark is false. Both true_exp and false_exp are always evaluated prior to valuating the relational expression. Therefore, you should not write an equation such as
#{sind(20.0*a)>cosd(20.0*a) ? a=sind(20.0) : a=cosd(20.0)}
since the value of a can change during the evaluation of the expression. Instead, this equation should be written as:
#{a = (sind(20.0*a)>cosd(20.0*a) ? sind(20.0) : cosd(20.0))}
White space in APREPRO can be important. For example, the following expressions will parse correctly:
x_coord-1 and x_coord -1
The following expressions will not parse:
x_coord- 1 and x_coord - 1
The operator must not be separated from the operand by white space.
Please refer to the current APREPRO documentation for details.
a = 10*PI
switch(10*PI + sin(0))
... This is ignored since it is after the switch, but before any case() statements
case(1)
... This is not executed since 1 is not equal to 10*PI+sin(0)
case(a)
... This is executed since a matches the value of 10*PI+sin(0)
case(10*PI+sin(0))
... This is not executed since a previous case was executed.
default
... This is not executed since a previous case was executed.
endswitch
... This is executed since the switch construct
is finished.