Exportizer Pro expression engine allows you to execute Pascallike 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.
Notes
1. The expressions and functions are calculated "on the fly" before they are outputted to target document or table.
2. Names of functions and operators are case insensitive.
3. Parameters of parameterized functions may be constants (literals) or expressions.
4. String literals must be enclosed in single quotes. If a literal includes quote marks, each of them must be doubled.
5. Multiline 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.
6. 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:
12 + abs(sqrt(5)  2)/3 
Arithmetic expression 
25  5 >= 14 
Logical expression 
'File name: ' + dataset_field_val(1, 'FileName') 
String expression 
date + 4 
Date expression. Adds four days to current date. It is vaild because dates are compatible with numbers. 
iif(length(Target_File_Name(1)) > 25, 'yes', 'no') 
Complex expression 
Examples of invalid expressions:
12 / target_file_name(1) 
Illegal use of string function in arithmetic expression (type mismatch) 
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. 
5 <> False 
Illegal comparison of a numeric and boolean constants 
power(4) 
Missing a second argument for power function 
iif(length(Target_File_Name(1) > 25, 'yes', 'no') 
Missing right parenthesis for length function 
Here, the expression engine operators and functions are described.
Operators
Arithmetic. 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). 
 
Substraction 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. 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 below.
Database related
StepNo parameter specifies the export step, in which the function must be calculated (see note 6 above). It is used only in HTML export context; in other cases its value is ignored. 
General 
dataset_field_val(
StepNo Integer,
FieldName String
): <FieldType> 
Returns value of field FieldName of the current dataset. The type of the returned value depends on the database field type. 
dataset_param_val(
StepNo Integer,
ParamName String
): <ParamType> 
Returns value of query parameter ParamName (if the current dataset is a parameterized query). The type of the returned value depends on the parameter type. 
dataset_field_is_null(
StepNo Integer,
FieldName String
): Boolean 
Returns
True, when value of field FieldName of the current dataset is null, and False in other cases. 
dataset_nvl(
StepNo Integer,
FieldName String,
SubstVal <FieldType>
): <FieldType> 
Returns SubstVal,
when value of field FieldName of the current dataset is null, and the field value in another case. The type of SubstVal must match the type of the FieldName field. 
query_res(
StepNo Integer,
SqlText String
): <FieldType> 
Returns result of the onefield query, specified by SQL text SqlText. The type of the returned value depends on the database field type. 
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 up 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.
GroupLevel is reserved for future use and currently must be 0. 
Standard (similar to aggregate functions in SQL) 
dataset_row_count(
StepNo Integer,
GroupLevel Integer
): Integer 
Returns the current dataset row count (accumulating). Actually, inside the dataset rows loop, it returns the current row number. 
dataset_min(
StepNo Integer,
GroupLevel Integer,
FieldName String
): Integer 
Returns the lowest value in FieldName 
dataset_max(
StepNo Integer,
GroupLevel Integer,
FieldName String
): Integer 
Returns the highest value in FieldName 
dataset_sum(
StepNo Integer,
GroupLevel Integer,
FieldName String
): Integer 
Sums values in FieldName 
dataset_avg(
StepNo Integer,
GroupLevel Integer,
FieldName String
): Integer 
Returns the average value in FieldName 
dataset_count(
StepNo Integer,
GroupLevel Integer,
FieldName String
): Integer 
Returns count of nonempty values in FieldName 
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
): Integer 

dataset_max_ex(
StepNo Integer,
GroupLevel Integer,
FieldName String,
Condition String
): Integer 

dataset_sum_ex(
StepNo Integer,
GroupLevel Integer,
FieldName String,
Condition String
): Integer 

dataset_avg_ex(
StepNo Integer,
GroupLevel Integer,
FieldName String,
Condition String
): Integer 

dataset_count_ex(
StepNo Integer,
GroupLevel Integer,
FieldName String,
Condition String
): Integer 

Note
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 
Returns an absolute value of numeric x 
frac(
x Numeric
): Numeric 
Returns fractional part of numeric x 
int(
x Numeric
): Numeric 
Returns integer part of numeric x 
round(
x Numeric
): Numeric 
Returns the value of numeric x rounded to the nearest whole number 
sqrt(
x Numeric
): Numeric 
Returns square root of numeric x 
power(
x Numeric,
y Numeric
): Numeric 
Raises numeric base x
to numeric power y 
exp(
x Numeric
): Numeric 
Returns the exponential of numeric x 
ln(
x Numeric
): Numeric 
Returns the natural (base e) logarithm of numeric x 
cos(
x Numeric
): Numeric 
Returns the cosine of numeric x,
where x is given in radians 
sin(
x Numeric
): Numeric 
Returns the sine of numeric x,
where x is given in radians 
tan(
x Numeric
): Numeric 
Returns the tangent of numeric x,
where x is given in radians 
atan(
x Numeric
): Numeric 
Returns the arc tangent of numeric x, that is, the value whose tangent is x 

Date and time 
date: Date 
Returns current date 
time: Time 
Returns current time 
add_date_time(
x DateTime,
y Numeric
): DateTime 
Adds y days to date/time x. y can be an integer or floatingpoint number. For example, 2.5 means two days and 12 hours. 
compare_date_time(
Date1 DateTime,
Date2 Numeric
): Numeric 
Returns an integer indicating the result of comparison of the date/time Date1 and date/time Date2: 0 when Date1 = Date2, 1 when Date1 > Date2, and 1 when Date1 < Date2. 
date_time_diff(
Date1 DateTime,
Date2 DateTime
): Numeric 
Returns difference in days (as floatingpoint number) between date/time Date1 and date/time Date2 
format_date_time(
x DateTime,
Mask String
): String 
Formats a date/time x using mask Mask. For example, to display only current month, use date for the first parameter and 'm' or 'mmmm' for the second one. 

HTML related (work in HTML export context) 
doc_title: String 
Returns HTML document title as it was specified in export options 
target_file_name(
StepNo Integer
): String 
Returns full path of target HTML file as it was specified in export options. StepNo specifies the export step, in which this function must be calculated (see note 6 here). 

File related 
file_created(
FileName String
): DateTime 
Returns the date and time the file FileName was created. FileName should be full file path. 
file_last_modified(
FileName String
): DateTime 
Returns the date and time the file FileName was last modified. FileName should be full file path. 
file_last_accessed(
FileName String
): DateTime 
Returns the date and time the file FileName was last accessed. FileName should be full file path. 
file_size(
FileName String
): Numeric 
Returns the size of the file FileName in bytes. FileName should be full file path. 
file_version( FileName String ): Numeric 
Returns the version of the file FileName. FileName should be full file path. 
extract_file_ext(
FileName String
): String 
Extracts the extension of the file FileName (with period) 
extract_file_name(
FileName String
): String 
Extracts file name from the full file path FileName 
extract_file_dir(
FileName String
): String 
Extracts file path (without \ character at the end) from the full file path FileName 
extract_file_path(
FileName String
): String 
Extracts file path (with \ character at the end) from the full file path FileName 
extract_file_text( FileName String ): String 
Extracts text from the text file FileName. FileName should be full file path. 
file_exists( FileName String ): Boolean 
Returns True if file FileName exists, False otherwise 
dir_exists( DirectoryName String ): Boolean 
Returns True if directory DirectoryName exists, False otherwise 

Miscelanious 
to_number(
x <AnyType>
): Numeric 
Converts x to number 
to_string(
x <AnyType>
): String 
Converts x to string 
format_float(
x Numeric,
Mask String
): String 
Formats a numeric x using mask Mask. For example, to always display two decimal places after the floating point, use '0.00' for the second parameter. 
lpad(
Str String,
Count Numeric,
Char String
): String 
Adds Char characters to the leftside of a string Str. Count is the number of characters to return. 
rpad(
Str String,
Count Numeric,
Char String
): String 
Adds Char characters to the rightside of a string Str. Count is the number of characters to return. 
iif(
Condition Boolean,
x <AnyType>,
y <AnyType>
): <AnyType> 
Returns x if Condition evaluates to True, or y in another case 
upper(
Str String
): String 
Converts a string Str to upper case 
lower(
Str String
): String 
Converts a string Str to lower case 
capitalize(
Str String
): String 
Converts first characters of every word in a string Str to upper case 
pretty(
Str String
): String 
Makes the first character of string Str in upper case and the rest in lower case 
length(
Str String
): Integer 
Returns length (count of characters) of a string Str 
pos(
SubStr String,
Str String
): Integer 
Returns position of substring SubStr in string Str 
substr(
Str String,
Index Integer,
Count Integer
): String 
Returns a substring of a string Str, containing Count characters starting at Index position 
substr_count(
Str String,
SubStr String
): Integer 
Returns the number of times the substring SubStr occurs in string Str 
trim(
Str String
): String 
Trims leading and trailing spaces and control characters from a string Str 
trim_left(
Str String
): String 
Trims leading spaces and control characters from a string Str 
trim_right(
Str String
): String 
Trims trailing spaces and control characters from a string Str 
string_replace(
Str String,
SubStr Integer,
NewSubStr Integer
): String 
Replaces all occurancies of substring SubStr with substring NewSubStr in text Str 
concat(
Str1 String,
Str2 Integer
): String 
Returns a string that is the result of concatenating string Str1 to string Str2 
ordinal_number(
x Integer,
Language String,
Case Integer,
Gender Integer
): String 
Returns the original number and the ordinal suffix of integer x.
Language is the language in which the result should be represented. Possible values: 'enUS' (American English), 'ukUA' (Ukrainian).
Case (from 'A' to 'F') and Gender ('M', 'F', 'N') are for Ukrainian language only. 
quantitative_numeral(
x Integer,
Language String,
Case Integer,
Gender Integer
): String 
Returns the quantitative numeral of integer x.
Language is the language in which the result should be represented. Possible values: 'ukUA' (Ukrainian).
Case (from 'A' to 'F') and Gender ('M', 'F', 'N') are for Ukrainian language only. 
number_to_words(
x Numeric,
Language String,
Options String
): String 
Converts number x to its representation in words.
Language is the language in which the result should be represented. Possible values: 'enUS' (American English), 'ukUA' (Ukrainian).
Options is a pipe separated list of options in OptionName=OptionValue format.
Allowed options:
 ShowZeroSubunits. Instructs either to include fractional part of the number if it equals to zero. Possible values: True or False. Default value: False.
 ProcessSubunits. Instructs either to convert fractional part of the number to words. Possible values: True or False. Default value: False.
 UnitsSubunitsSeparator. Specifies a separator between an integer and fractional parts of the number. Default value is a space character.
 SubunitsDimension. Specifies dimension for fractional part of the number. Default value is 2. This option is ignored when ProcessSubunits is True.
 CurrencyCode. Specifies currency code in ISO 4217 format. Currently, only the following currency codes are supported: USD, EUR, UAH. Using this option instructs to interpret the number as currency value and add main currency and fractional currency names (i.e., units and subunits).
 Type. Specifies the type of the conversion. Possible values: regular, fraction. This option is meaningful only if Language is 'ukUA'.
 UnitsShortened. Instructs to shorten the main currency name (units) if it is used. This option is meaningful only if Language is 'ukUA'.
 SubunitsShortened. Instructs to shorten the fractional currency name (subunits) if it is used. This option is meaningful only if Language is 'ukUA'.
Examples:
Expression 
Result 
number_to_words( dataset_field_val(1, 'pay_sum'), 'enUS', 'UnitsSubunitsSeparator= and CurrencyCode=USDSubunitsDimension=2ShowZeroSubunits=true' ) 

number_to_words( 3467.35, 'enUS', 'UnitsSubunitsSeparator= and CurrencyCode=USDShowZeroSubunits=true' ) 
three thousand four hundred sixty seven dollars and 35 cents 
number_to_words( 3467.35, 'enUS', 'UnitsSubunitsSeparator= and SubunitsDimension=4ShowZeroSubunits=true' ) 
three thousand four hundred sixty seven and 3500 


