Exportizer Pro/Exportizer Enterprise expression engine allows you to execute Pascal-like expressions, which can be embedded in dynamic elements during the data exporting. You can use them in several situations:
- in the field mappings, instead of the source fields;
- in the field mappings, as totals expressions;
- in the field mappings, to calculate dynamic target file names for exporting contents of the fields to individual files;
- 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).
An expression returns one value. Available types of returning values:
- Integer
- Numeric (floating-point number)
- String
- DateTime
- Boolean
- 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 can 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.
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 valid because dates are numbers internally.}
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}
Operators
ArithmeticThese operators work with numbers and return numbers (except + operator, which can be used for string concatenation). |
||||||||||||||||||||
|
||||||||||||||||||||
LogicalThese operators work with boolean constants or expressions of any kind, which return a boolean value, and return boolean True or False. |
||||||||||||||||||||
|
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_hex_val( StepNo Integer, FieldName String | FieldIndex Integer ): Stringdataset_field_is_null( StepNo Integer, FieldName String | FieldIndex Integer ): Booleandataset_nvl( StepNo Integer, FieldName String | FieldIndex Integer, SubstVal <FieldType> ): <FieldType>dataset_field_exists( StepNo Integer, FieldName String ): Booleandataset_param_val( StepNo Integer, ParamName String ): <ParamType>query_res( StepNo Integer, SqlText String ): <FieldType>dbnull: UnknownStatistical (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 ): Integerdataset_min( StepNo Integer, GroupLevel Integer, FieldName String ): Numericdataset_max( StepNo Integer, GroupLevel Integer, FieldName String ): Numericdataset_sum( StepNo Integer, GroupLevel Integer, FieldName String ): Numericdataset_avg( StepNo Integer, GroupLevel Integer, FieldName String ): Numericdataset_count( StepNo Integer, GroupLevel Integer, FieldName String ): IntegerConditional
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 ): Integerdataset_min_ex( StepNo Integer, GroupLevel Integer, FieldName String, Condition String ): Numericdataset_max_ex( StepNo Integer, GroupLevel Integer, FieldName String, Condition String ): Numericdataset_sum_ex( StepNo Integer, GroupLevel Integer, FieldName String, Condition String ): Numericdataset_avg_ex( StepNo Integer, GroupLevel Integer, FieldName String, Condition String ): Numericdataset_count_ex( StepNo Integer, GroupLevel Integer, FieldName String, Condition String ): IntegerIt is not recommended to use nested calls of statistical functions (i.e. when Condition contains statistical functions calls), because the application 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 a 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 ): Numericceil( x Numeric ): Numericfrac( x Numeric ): Numericint( x Numeric ): Numericmax( x Numeric, y Numeric ): Numericmin( x Numeric, y Numeric ): Numericround( x Numeric ): Integersqrt( x Numeric ): Numericpower( x Numeric, y Numeric ): Numericexp( x Numeric ): Numericln( x Numeric ): Numericcos( x Numeric ): Numericsin( x Numeric ): Numerictan( x Numeric ): Numericatan( x Numeric ): NumericDate and Time
date: DateTimetime: DateTimedate_time: DateTimeadd_date_time( x DateTime, y Numeric ): DateTimecompare_date_time( Date1 DateTime, Date2 DateTime ): Integerdate_time_diff( Date1 DateTime, Date2 DateTime ): Numericformat_date_time( x DateTime, Mask String ): StringHTML Related (work in export to HTML context)
doc_title: StringFile Related
target_file_name( StepNo Integer ): Stringfile_created( FileName String ): DateTimefile_last_modified( FileName String ): DateTimefile_last_accessed( FileName String ): DateTimefile_size( FileName String ): Numericfile_version( FileName String ): Stringextract_file_ext( FileName String ): Stringextract_file_name( FileName String ): Stringextract_file_dir( FileName String ): Stringextract_file_path( FileName String ): Stringextract_file_text( FileName String ): Stringfile_exists( FileName String ): Booleandir_exists( DirectoryName String ): BooleanMiscellaneous
to_number( <AnyType> String ): Numericto_string( <AnyType> String ): Stringparse( x <AnyType> ): <AnyType>format_float( x Numeric, Mask String ): Stringlpad( Str String, Count Numeric, Char String ): Stringrpad( Str String, Count Numeric, Char String ): Stringiif( Condition Boolean, x <AnyType>, y <AnyType> ): <AnyType>char( x Integer ): Stringupper( Str String, ): Stringlower( Str String, ): Stringcapitalize( Str String, ): Stringpretty( Str String, ): Stringlength( Str String, ): Integerpos( SubStr String, Str String ): Integersubstr( Str String, Index Integer, Count Integer ): Stringsubstr_count( Str String, SubStr String ): Integertrim( Str String, ): Stringtrim_left( Str String, ): Stringtrim_right( Str String, ): Stringstring_replace( Str String, SubStr String, NewSubStr String ): Stringconcat( Str1 String, Str2 String ): Stringordinal_number( x Integer, Language String, Case String, Gender String ): Stringquantitative_numeral( x Integer, Language String, Case String, Gender String ): Stringnumber_to_words( x Numeric, Language String, Options String ): Stringrgb( Red Integer, Green Integer, Blue Integer ): String



