Functions

The general form of calling a function is:

FUNCTION (<param1>, <param2>, ... <paramN>)

Currently defined functions are:

Function Description
ABS(x) Returns the absolute value of x. If x is not defined, returns an undefined value.
CUTHIGHS([GRADE FIELD], CutValue) The CUTHIGHS_TO function takes two parameters: the field value and a high value, if the cut value is not defined it will return null, if the high value is not defined it will return the cut value.
DEFINED(x) x – variable. Check if it is defined (x exists and was assigned a value which is not undefined (NIL or BLANK).
 

=IN("VALUE", [FIELD1], [FIELD2], [FIELD3])

EXP(x) Returns the ANTILOG BASE E of x.
EXP10(x) Returns the ANTILOG BASE 10 of x.
IN(y, x1, ... xn) The IN function takes at least two parameters, the first one is the value that gets compared. Other parameters are the values to compare to. If a match is found, the function returns logical TRUE. For example:
INT(x) Returns the integer part of the number. If x is not defined, returns an undefined value.
RGB(r,g,b) Calculate an RGB colour value on the fly, for example, when loading points.
  r, g, b values must be in the range [0, 255]
LN(x) Returns the NATURAL LOGARITHM of x
LG(x) Returns the BASE-10 LOGARITHM of x.
MIN(x1, x2, ... xn) Returns the minimal defined value of all arguments. If no argument is a defined value, returns an undefined value.
MAX(x1, x2, ... xn) Returns the maximal defined value of all arguments. If no argument is a defined value, returns an undefined value.
RANDOM() Generates a random value. If there are no parameters the generated number is in the range [0,1]. One parameter defines a maximum and the generated number is in the range [0, max]. Two parameters define a minimum and a maximum and the generated number is in the range [min, max].
ROUND(x, n) Rounds the value of x to n decimal places. If either x or n is undefined, returns an undefined value.
ROUNDSIG(x, n) Rounds the value of x to a given number of (n) significant figures.
SQRT(x) Calculates the square root of x. If x is not defined, returns an undefined value.

Trigonometric functions and angular calculations

For the trigonometric functions, input values are expected to be in degrees and decimals of a degree (DDD.DDDD) as are the results.

Function Description
SIN(x) Returns the SINE of x.
COS(x) Returns the COSINE of x.
TAN(x) Returns the TANGENT of x.
ASIN(x) Returns the ARCSINE of x.
ACOS(x) Returns the ARCCOSINE of x.
ATAN(x) Returns the ARCTANGENT of x.
ATAN2(y, x) Returns the ARCTANGENT of y/x. (if x equals 0, ATAN2 returns 180 if y is positive, -180. if y is negative, or 0 if y is 0.) If either x or y is undefined, the return value is undefined.
ADDANGLE(x1, x2, ... xn) Adds up all passed parameters, making sure the result is in the range [0, 360).
SUBANGLE(x1, x2, ... xn) Subtracts all passed parameters, making sure the result is in the range [0, 360).
DMS2DEG(x) Converts an angle in DMS format (x) to decimal degrees.
DEG2DMS(x) Converts an angle in decimal degrees format (x) to DMS format.

Tips

  1. Be aware of the type conversion in your expression. Remember that apart from a few exceptions, the type of the result is the type of the leftmost operand. Note therefore, that “5" + 5 equals “55" and not 10. Note also that if any operand is undefined the result of the expression will also be undefined.
  2. Remember that the variable type is the type of the corresponding file field.
  3. Function and variable names referred to in the expression are matched only when they are actually needed to produce a value. Use the DEFINED function to ensure that a variable exists and has a value before referring to it. 2 + MCAF is unsafe, since MCAF might not exist or might not have a value.
  4. Use 2 + if DEFINED (MCAF) then MCAF else <some_defined_value> fi instead.

  1. Use parentheses to ensure that the computation order is correct.
  2. Remember that ALL parts of the 'if' operator are compulsory. Don't forget the 'fi' to mark the end of your conditional operator.

Expression Editor