Exportizer Pro expression engine allows you to execute Pascal-like expressions, which can be embedded in dynamic elements during export (for example, in field mappings or when exporting database data to HTML using HTML templates).

The expressions can consist of functions (nesting of any depth), arithmetical and logical operators, and literals (numeric, string, or boolean). Expression returns one value of numeric, string, or boolean type.

The expressions and functions are calculated "on the fly" before they are outputted to target document or table.
Names of functions and operators are case insensitive.
Parameters of parameterized functions may be constants (literals) or expressions.
String literals must be enclosed in single quotes. If a literal includes quote marks, each of them must be doubled.
Multi-line string literals are not allowed. If you want to pass big text as parameter, you can split it on less separate string literals and concatenate them using + operator.
In some functions, there is a StepNo parameter. It is meaningful only when used in HTML templates (see below), in all other cases it should be 1.

HTML template can be filled with dynamic data in more than one step. For example, if your HTML document consists of several tables, which must be filled with database data from different datasets, you can fill them only in several export steps (usually, one dataset per step). That's why database related and some other functions have a StepNo parameter. When exporting a dataset to HTML using HTML template, it is also possible to specify an export step number (it is 1 by default). During the export procedure, only those expressions will be calculated where the StepNo parameter of expression function(s) is not present or matches with a step number, specified in export options. For example, the database_field_val(2, 'payment_sum')/100 expression will be calculated only in the second export step.

Combining different StepNo parameters in one expression (for example, database_field_val(1, 'total_sum') + database_field_val(2, 'payment_sum')) is possible, but such expression should be written so that functions with smaller StepNo will be calculated earlier.

Examples of valid expressions

Correct expression 12 + abs(sqrt(5) - 2)/3 {Arithmetic expression}

Correct expression 25 - 5 >= 14 {Logical expression}

Correct expression 'File name: ' + dataset_field_val(1, 'FileName') {String expression}

Correct expression date + 4 {Date expression. Adds four days to current date. It is valid because dates are numbers internally.}

Correct expression iif(length(Target_File_Name(1)) > 25, 'yes', 'no') {Complex expression}

Examples of invalid expressions

Incorrect expression 12 / target_file_name(1) {Illegal use of string function in arithmetic expression (type mismatch)}

Incorrect expression concat(cos(dataset_field_val(1, 'FuncParam')), ' is larger') {Illegal use of floating point number as an argument of string concatenation. There must be explicit type casting using to_string function.}

Incorrect expression 5 <> False {Illegal comparison of a numeric and boolean constants}

Incorrect expression power(4) {Missing a second argument for power function}

Incorrect expression iif(length(Target_File_Name(1) > 25, 'yes', 'no') {Missing right parenthesis for length function}

Operators

Arithmetic

These operators work with numbers and return numbers (except + operator, which can be used for string concatenation).
+ Addition of numbers. Can be also used for concatenating string operands (as an alternative for concat function).
- Subtraction of numbers
* Multiplication of numbers
/ Division of numbers
^ Raises left operand to power, specified by the right operand (as an alternative for power function)
div Integer division. It is division in which the fractional part (remainder) is discarded.
mod Remainder of integers. It divides two numbers and returns only the remainder.

Logical

These operators work with boolean constants or expressions of any kind, which return a boolean value, and return boolean True or False.
not Logical NOT. Returns False if its single operand can be converted to True; otherwise, returns True.
and Logical AND. Returns True if both operands are True; otherwise, returns False.
or Logical OR. Returns True if either operand is True; if both are False, returns False.
xor Exclusive OR. Returns True if one operand is True and the other is False; otherwise, returns False.
= Equality
<> Inequality
> Greater than
>= Greater than or equal
< Less than
<= Less than or equal

Functions

Use functions to calculate values. Each function returns one value. Function parameters can be constants or expressions (including recursive function calls), unless otherwise noted in function descriptions.

Database related

General

dataset_field_val(
  StepNo Integer,
  FieldName String | FieldIndex Integer
): <FieldType>
dataset_field_is_null(
  StepNo Integer,
  FieldName String | FieldIndex Integer
): Boolean
dataset_nvl(
  StepNo Integer,
  FieldName String | FieldIndex Integer,
  SubstVal <FieldType>
): <FieldType>
dataset_field_exists(
  StepNo Integer,
  FieldName String
): Boolean
dataset_param_val(
  StepNo Integer,
  ParamName String
): <ParamType>
query_res(
  StepNo Integer,
  SqlText String
): <FieldType>

Statistical (aggregate)

These functions perform calculation on current dataset data. Unlike other functions, statistical functions accumulate data of each record of dataset field, therefore they need more resources and their using (especially for conditional functions) may slow down processing for large datasets.

It is strongly recommended to use these functions only inside or after loop(s) through dataset rows, otherwise they will return inadequate values.

Standard (similar to aggregate functions in SQL)

dataset_row_count(
  StepNo Integer,
  GroupLevel Integer
): Integer
dataset_min(
  StepNo Integer,
  GroupLevel Integer,
  FieldName String
): Numeric
dataset_max(
  StepNo Integer,
  GroupLevel Integer,
  FieldName String
): Numeric
dataset_sum(
  StepNo Integer,
  GroupLevel Integer,
  FieldName String
): Numeric
dataset_avg(
  StepNo Integer,
  GroupLevel Integer,
  FieldName String
): Numeric
dataset_count(
  StepNo Integer,
  GroupLevel Integer,
  FieldName String
): Integer

Conditional

These functions work like standard statistical functions, but with one important difference: they check Condition for each row, and calculate only if it evaluates to True. It is important to write the Condition parameter in these functions as String constant (i.e. enclosed in single quotes) or a string deterministic expression (see below).

The parameters of these functions must be constants or deterministic expressions (i.e. return the same result any time they are called with a specific set of input values). The Condition parameter can use also nondeterministic expressions, but, as noted above, it should be written as string literal or string deterministic expression.

dataset_row_count_ex(
  StepNo Integer,
  GroupLevel Integer,
  Condition String
): Integer
dataset_min_ex(
  StepNo Integer,
  GroupLevel Integer,
  FieldName String,
  Condition String
): Numeric
dataset_max_ex(
  StepNo Integer,
  GroupLevel Integer,
  FieldName String,
  Condition String
): Numeric
dataset_sum_ex(
  StepNo Integer,
  GroupLevel Integer,
  FieldName String,
  Condition String
): Numeric
dataset_avg_ex(
  StepNo Integer,
  GroupLevel Integer,
  FieldName String,
  Condition String
): Numeric
dataset_count_ex(
  StepNo Integer,
  GroupLevel Integer,
  FieldName String,
  Condition String
): Integer
It is not recommended to use nested calls of statistical functions (i.e. when Condition contains statistical functions calls), because the program cannot guarantee the correct result of such calls.
But if you do this, try to avoid cyclic field references in these functions because this may cause unexpected results of expressions. For example, using FieldName inside Condition is a cyclic reference and should be avoided.

Examples of correct using of conditional statistical functions:

dataset_sum_ex(1, 0, 'PaymentSum', 'dataset_field_val(1, ''CustNo'') > 1000')

(this expression will sum data from PaymentSum field, when value of numeric field CustNo is larger then 1000)

dataset_count_ex(1, 0, 'CustNo', 'dataset_field_val(1, ''Paid'')')

(this expression will return count of values from field CustNo, when value of boolean field Paid is True)

dataset_sum_ex(1, 0, 'BillSum', 'dataset_sum_ex(1, 0, ''OldBillSum'', ''dataset_field_val(1, ''''CustNo'''') > 0'') > 0')

(this function will return sum of values from field BillSum, when conditional sum of field OldBillSum is larger than 0)

Examples of incorrect using of conditional statistical functions:

dataset_count_ex(1, 0, 'CustNo', 'yes')

(error: not boolean constant cannot be used as condition)

dataset_sum_ex(1, 0, 'BillSum', 'dataset_sum_ex(1, 0, ''OldBillSum'', ''dataset_sum_ex(1, 0, ''''BillSum'''', True) > 0'') > 0')

(error: cyclic reference for field BillSum)

Mathematical

abs(
  x Numeric
): Numeric
frac(
  x Numeric
): Numeric
int(
  x Numeric
): Numeric
round(
  x Numeric
): Integer
sqrt(
  x Numeric
): Numeric
power(
  x Numeric,
  y Numeric
): Numeric
exp(
  x Numeric
): Numeric
ln(
  x Numeric
): Numeric
cos(
  x Numeric
): Numeric
sin(
  x Numeric
): Numeric
tan(
  x Numeric
): Numeric
atan(
  x Numeric
): Numeric

Date and time

date: DateTime
time: DateTime
add_date_time(
  x DateTime,
  y Numeric
): DateTime
compare_date_time(
  Date1 DateTime,
  Date2 DateTime
): Integer
date_time_diff(
  Date1 DateTime,
  Date2 DateTime
): Numeric
format_date_time(
  x DateTime,
  Mask String
): String

HTML related (work in HTML export context)

doc_title: String
target_file_name(
  StepNo Integer
): String

File related

file_created(
  FileName String
): DateTime
file_last_modified(
  FileName String
): DateTime
file_last_accessed(
  FileName String
): DateTime
file_size(
  FileName String
): Numeric
file_version(
  FileName String
): String
extract_file_ext(
  FileName String
): String
extract_file_name(
  FileName String
): String
extract_file_dir(
  FileName String
): String
extract_file_path(
  FileName String
): String
extract_file_text(
  FileName String
): String
file_exists(
  FileName String
): Boolean
dir_exists(
  DirectoryName String
): Boolean

Miscellaneous

to_number(
  <AnyType> String
): Numeric
to_string(
  <AnyType> String
): String
format_float(
  x Numeric,
  Mask String
): String
lpad(
  Str String,
  Count Numeric,
  Char String
): String
rpad(
  Str String,
  Count Numeric,
  Char String
): String
iif(
  Condition Boolean,
  x <AnyType>,
  y <AnyType>
): <AnyType>
upper(
  Str String,
): String
lower(
  Str String,
): String
capitalize(
  Str String,
): String
pretty(
  Str String,
): String
length(
  Str String,
): Integer
pos(
  SubStr String,
  Str String
): Integer
substr(
  Str String,
  Index Integer,
  Count Integer
): String
substr_count(
  Str String,
  SubStr String
): Integer
trim(
  Str String,
): String
trim_left(
  Str String,
): String
trim_right(
  Str String,
): String
string_replace(
  Str String,
  SubStr String,
  NewSubStr String
): String
concat(
  Str1 String,
  Str2 String
): String
rgb(
  Red Integer,
  Green Integer,
  Blue Integer
): String
ordinal_number(
  x Integer,
  Language String,
  Case String,
  Gender String
): String
quantitative_numeral(
  x Integer,
  Language String,
  Case String,
  Gender String
): String
number_to_words(
  x Numeric,
  Language String,
  Options String
): String