CIB merge technical documentation (EN)
3. CIB merge as a document interpreter
3.5. Supported field commands
Overview of basic field commands
Supported text functions
Supported date functions
Rules for processing text and date functions
General
MS-Office provides about 85 different field commands that can be used to program dynamic documents. All commands that are not directly related to the formatting of text are evaluated and supported by the CIB merge component during a merge process.
The interpretation of the remaining field commands that are important for the layout/print display (e.g. (total) page numbering, print date, signature fields, etc.) is reserved for the CIB format/output component. CIB merge passes these field commands unfiltered in the result document.
From CIB merge version
3.13.7:
The same behavior applies to a calculation expression that contains references
to table elements: The expression is passed to the result document unfiltered.
Overview of basic field commands
The following field commands of a document are interpreted directly by the CIB merge component during a merge process and dynamically converted into the output file (the field commands here are only listed alphabetically and not described with their full syntax):
Field command |
Description |
COMPARE |
Compares two values and returns the numeric value 1 if the comparison is true and 0 (zero) if the comparison is false. |
DATA |
|
DATE |
Inserts the current date. |
IF |
Compares arguments under certain conditions. Can be extended optionally to a loop instruction. |
INCLUDEPICTURE |
Inserts a graphic from a file. Is only executed by CIB merge in conjunction with the call parameter --EMBED. Otherwise the interpretation is only carried out by CIB format/output. |
INCLUDEPICTURE "?graphic file" (from CIB merge Version 3.9.174) |
Returns 0 if the file does not exist, otherwise 1. |
INCLUDETEXT |
Inserts a text from a file. "Please note in this context the possible field switch NEWLISTID" |
INCLUDETEXT "?text file" |
Returns 0 if the file does not exist, otherwise 1. |
INFO |
Inserts information from the Properties dialog box. |
MERGEFIELD |
Defines a placeholder with a name that will be replaced by a delivered variable content later. |
MERGEREC <Alias-Name> |
Inserts the number that the current record has in the input file (or table) <alias name>. |
MERGEREC ?<Alias-Name> |
Returns 0 if there are no more datasets in the file (or table) <alias name>. |
MERGEREC #<Alias-Name> (from CIB merge version 3.12.1) |
Returns the exact number of datasets in the file (or table) <alias name>. Attention: This function can be resource-intensive with CSV data sources! |
MERGEREC ##<Alias-Name> (from CIB merge version 3.12.1) |
Returns status information about the number of datasets in the file (or table) <alias name>. Values: 1 one dataset 2 two or more datasets Attention: This function has no negative effect on the resources of CSV data sources. |
NEXT |
Moves to the next dataset or node in the data supply. |
NEXTIF |
Moves to the next dataset or node in the data supply when a certain condition is met. |
QUOTE |
Inserts text into the document. |
REF |
Defines a placeholder with a name that will be replaced by a delivered variable content later. |
REF "?variable" (from CIB merge version 3.9.191) |
Returns 0 if the variable does not exist, otherwise 1. |
TO DO: REF DAT |
|
TO DO: NEXT DEF |
|
SET |
Assigns new text to a bookmark. |
SKIPIF |
Skips a dataset or node in the data supply during a mail merge according to a condition. Usage with alias names is not possible! |
TIME |
Inserts the current time. |
= Expression |
Calculates the result of an expression (= formulas). CIB merge supports very extensive functions, even in complicated formulas. From CIB merge version 3.11.0 the text functions described in the following chapter are supported. |
Some of these field commands allow an extension of their functionality with additional switches.
For example, loop instructions can be used to create dynamic tables of any length. It is also possible to insert text modules dynamically.
Supported text functions
From CIB merge version 3.12.0 the text
functions described in the following chapter are supported.
Notes:
- The possibility for linked (multiple) processing of text functions is described here.
- Fixed texts (strings) can be used as parameters of a text function. The content of a string must be specified in quotation marks. The string itself must not contain quotation marks.
Text function (syntax) |
Description |
TRIM(text) |
Deletes spaces in a text that are not individually between words and thus serve as separators. You can use TRIM for texts that you have copied from other application programs and that may contain unwanted spaces. Parameters: text (type text, required) The text, from which the spaces should be removed. Example: =Trim( " abc " ) results in abc |
LEN(text) |
Returns the number of characters in a string. Parameters: text (type text, required) The text from which you want to find out its length. Blank spaces count as characters. Example: = LEN( "ab abc" ) results in 6 |
FIND(find_text;within_text; start_num) |
FIND searches for a character string within another and returns the position of the searched character string from the first character of the other character string. Parameters: find_text (type text, required) Sets the text to search. within_text (type text, required) Sets the text, in which you search with find_text. start_num (type number, required) Specifies the character to begin the search with. The first character corresponding to find_text has the number one 1. Example: =FIND( "b"; "abc", 1 ) results in 2 Notes: |
SEARCH(find_text; within_text; start_num) |
SEARCH searches for a character string within another character string and returns as result the number of the starting position of the first character string, counted from the first character of the second character string. Parameters: find_text (type text, required) is the text you want to search for. A string specified as find_text can contain the placeholder characters question mark (?) and asterisk (*). A question mark replaces one character, an asterisk replaces any character string. If you search for a question mark or an asterisk, you must enter two backslashes (\\) before the character you want to search for. within_text (type text, required) is the text in which to search for find_text. start_num (type number, required) Specifies the character at which the search should start. The first character belonging to find_text has the number 1. Example:
=SEARCH(
"b"; "ABC", 1 ) results in 2 Notes: |
MID(text; start_num; num_chars) |
The MID function returns a certain number of related characters from a given string. Parameters: text (type text, required) Text, to return characters from. start_num(type number, required) Character position in text, where the part to be extracted begins. num_chars(type number, required) Returns the number of characters that MID should return from text. Example: =MID( "abc"; 2; 1 ) results in b Notes:
|
SUBSTITUTE(text; old_text; new_text; instance_num) |
Replaces old with new text in a string. You can use SUBSTITUTE whenever you want to replace a specific character string within a text. You should always use REPLACE if you want to replace a character string starting at a specific position within a text. Parameters: text (type text, required) is the text with the characters to be replaced. old_text (type text, required) is the text to be replaced. new_text (type text, required) is the text to be replaced with old_text. instance_num (type number, required) Specifies how often old_text should be replaced with new_text. If you specify instance_num, only this occurrence of old_text will be replaced; otherwise, old_text will be replaced by new_text wherever it occurs in. Example: =SUBSTITUTE( "abcbcbcd"; "bc"; "d"; 2 ) results in addbcd |
REPLACE(old_text; start_num; num_chars; new_text) |
REPLACE replaces a character string of the specified length in the text from the specified position onwards with another character string. Parameters: old_text (type text, required) is the text, in which you want to replace an amount of characters. start_num (type number, required) The position of the character in old_text where to start replacing with new_text. num_chars (type number, required) The amount of characters in old_text, that REPLACE replaces with new_text. new_text (type text, required) The text with which you want to replace characters in old_text. Example: =REPLACE( "abcd"; 2; 2; "d" ) results in add |
LOWER(text) |
Converts a text to lower case. Parameters: text (type text, required) The text to convert in lower case. Example: =LOWER( "ABC9" ) results in abc9 Note:
|
UPPER(text) |
Converts a text to upper case. Parameters: text (type text, required) The text to convert in upper case. Example: = UPPER( "abc9" ) results in ABC9 Note:
|
LEFT(text; num_chars) |
Cuts the specified number of characters starting from the left. Parameters: text (type text, required) The text string with the characters to be cut. num_chars (type number, required) Amount of characters to be returned. Example: =LEFT( "abc"; 2 ) results in ab Notes:
|
RIGHT(text; num_chars) |
Cuts the specified number of characters starting from the right. Parameters: text (type text, required) The text string with characters to cut. num_chars (type number, required) Amount of characters to be returned. Example: =RIGHT( "abc"; 2 ) results in bc Notes:
|
REPT(text; number_times) |
Repeats a text as often as specified. You can use REPT to repeat a text with a certain frequency. Parameters: text (type text, required) The text to be repeated. number_times (type number, required) A positive number indicating the number of repetitions Example: =REPT( "abc"; 2 ) results in abcabc Notes:
|
TOKENIZE(text; delimiters; tokenIdx) |
Splits a text into individual text parts using the specified separators and returns the part specified with tokenIdx (e.g. with tokenIdx = 3, the third part). Parameters: text (type text, required) The text to separate. delimiters (type text, required) List of delimiters. If using a comma as separator, it needs to be masked with a backslash (\). tokenIdx (Type number, required) Number of the text part to be returned. If the index is negative, counting starts from the end of the text Examples: =TOKENIZE( "a b c-d"; " -"; 4 ) results
in d Notes:
|
BEFORE(text; before_text) |
Returns the characters of text that precede the first occurrence of before_text in text, or returns an empty string if before_text is not included in text. Parameters: text (type text, required) Is the text from which the string is to be taken. before_text (type text, required) The text to be searched for, which marks the end of the character string to be extracted. Example: =BEFORE( "abcdefg"; "cd" ) results in ab Notes:
|
AFTER(text; after_text) |
Returns the characters of text that follow the first occurrence of after_text in text, or returns an empty string if after_text is not included in text. Parameters: text (type text, required) Is the text from which the string is to be taken after_text (type text, required) The text to be searched, which marks the beginning of the character string to be extracted. Example: =AFTER( "abcdefg"; "cd" ) returns in efg Notes:
|
FORMAT(text; format) |
Returns text in the format format. This function works similar to formatting numbers. Parameters: text (type text, required) Is the text to format. format (type text, required) Defines the format. (Details see below) Valid characters to specify the format: x Placeholder characters for one character of the specified text. Adding spaces and separators: Space will be displayed exactly as entered / will be displayed exactly as entered ( will be displayed exactly as entered ) will be displayed exactly as entered . will be displayed exactly as entered - will be displayed exactly as entered Examples: =Format(„abcdefghi“;“xxx
xxx xxx“) results in „abc def ghi“ Note:
|
Supported date functions
From version 3.12.12 CIB merge supports the date functions described below.
The date functions are defined analogous to
calculation or text functions in the form
{ =DATUMSFUNKTION }
{ =DATE FUNCTION }
into the document.
A requirement for these functions is that the date used as input (or a variable "date") has a valid date value and is formatted in a valid date format.
Date function (syntax) |
Description |
ADDDAYS(Date,AmountDays) \@ Format Return: Date |
Add days: Parameters: Date See requirement above AmountDays Integer Format Has to be a valid syntax for date formatting
|
ADDDAYS_VD(VDatum,AnzTage) \@ Format Rückgabe: Datum |
Tage addieren mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
ADDMONTHS(Date,AmountMonth) \@ Format Return: Date |
Add month: Parameters: Date See requirements above AmountMonth Integer Format Has to be a valid syntax for date formatting
|
ADDMONTHS_VD(VDatum,AnzMonate) \@ Format Rückgabe: Datum |
Monate addieren mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
ADDYEARS(Date,AmountYears) \@ Format Return: Date |
Add years: Parameters: Date See requirements above AmountYears Integer Format Has to be a valid syntax for date formatting
|
ADDYEARS_VD(VDatum,AnzJahre) \@ Format Rückgabe: Datum |
Jahre addieren mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
ADDWORKINGDAYS(Date,AmountDays, \@ Format Return: Date |
Add working days: Parameters: Date See requirements above AmoutDays Amount of days, integer Holidays Optionally, a list of public holidays can be specified, which are taken into account in the calculation. Syntax: dd.MM. Data separated by ";". WorkingDays Working days per week.
Values between 2 and 7, default is 5. Format Needs to have a valid syntax for date formatting Example: |
ADDWORKINGDAYS_VD(VDatum,AnzTage, \@ Format Rückgabe: Datum |
Werktage addieren mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
GETNEXTWORKINGDAY(Date,Holidays,WorkingDays) \@ Format Return: Date |
Next working day from date: Based on the value of the variable varDate, the next working day is determined taking the days off into account and output in the desired format. Parameters: Date See requirements above. Holidays Optionally, a list of public holidays can be specified, which are taken into account in the calculation. Syntax: dd.MM. Data separated by ";". WorkingDays Working days per week.
Values between 2 and 7, default is 5. Format Needs to have a valid syntax for date formatting Example: |
SUBTRACTDAYS(Date,AmountDays) \@ Format Return: Date |
Subtract days: A certain number of days is subtracted from the value of the Date variable and displayed in the desired format. Parameters: Date See requirement above AmountDays Integer Format Has to be a valid syntax for date formatting
|
SUBTRACTDAYS_VD(VDatum,AnzTage) \@ Format Rückgabe: Datum |
Tage subtrahieren mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
SUBTRACTMONTHS(Date,AmountMonth) \@ Format Return: Date |
Subtract months: A certain number of months is subtracted from the value of the variable Date and displayed in the desired format. Parameters: Date See requirement above AmountMonth Integer Format Has to be a valid syntax for date formatting
|
SUBTRACTMONTHS_VD(VDatum,AnzMonate) \@ Format Rückgabe: Datum |
Monate subtrahieren mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
SUBTRACTYEARS(Date,AmountYears) \@ Format Return: Date |
Subtract years: A certain number of years is subtracted from the value of the variable Date and output in the desired format. Parameters: Date See requirement above AmountYears Integer Format Has to be a valid syntax for date formatting
|
SUBTRACTYEARS_VD(VDatum,AnzJahre) \@ Format Rückgabe: Datum |
Jahre subtrahieren mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
SUBTRACTWORKINGDAYS(Date,AmountDays,Holidays,WorkingDays) \@ Format Return: Date |
Subtract working days: A certain number of working days is subtracted from the value of the variable varDate and displayed in the desired format. Parameters: Date See requirements above AmountDays Amount of working days, integer Holidays Optionally, a list of public holidays can be specified, which are taken into account in the calculation. Syntax: dd.MM. Data separated by ";". Optionally, a list of public holidays can be specified, which are taken into account in the calculation. Syntax: dd.MM. Data separated by ";". WorkingDays Working days per
week. Value between 2 and 7, default is 5. Format Has to be a valid syntax for date formatting Example: |
DATEDIF(Date1,Date2,Unit) Return: Integer |
Calculate date difference: The difference between the date values Date1 and Date2 is calculated. The time unit is controlled by the Unit parameter. Parameters: Date1 Unit Possible values: Y Difference in completed years M Difference in completed months D Difference in days MD Difference between the days (in days, ignoring month and year specification) YM Difference between the months (in months, ignoring day and year specification) YD Difference between days and months (in days, ignoring year specification)
|
DATEDIF_VD(VDatum1,VDatum2,Einheit) Rückgabe: Ganzzahl |
Datumsdifferenz berechnen mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
GETDAYDIFF(Date1,Date2) Return: Integer |
Calculate difference in days: The difference between the date values Date1 and Date2 is calculated in days. Parameters: Date1 |
GETDAYDIFF_VD(VDatum1,VDatum2) Rückgabe: Ganzzahl |
Differenz in Tagen berechnen mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
GETMONTHDIFF(Date1,Date2) Return: Integer |
Calculate difference in months: The difference between the date values Date1 and Date2 is calculated in months. Parameters: Date1 |
GETMONTHDIFF_VD(VDatum1,VDatum2) Rückgabe: Ganzzahl |
Differenz in Monaten berechnen mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
GETYEARDIFF(Date1,Date2) Return: Integer |
Calculate difference in years: The difference between the date values Date1 and Date2 is calculated in years. Parameters: Date1 |
GETYEARDIFF_VD(VDatum1,VDatum2) Rückgabe: Ganzzahl |
Differenz in Jahren berechnen mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
GETFIRSTOFMONTH(Date) \@ Format Return: Date |
First day of the month: The first day of the month of a given date is output in the desired format. Parameter: Date See requirements above Format Has to be a valid syntax for date formatting Example: |
GETFIRSTOFMONTH_VD(VDatum) \@ Format Rückgabe: Datum |
Erster Tag im Monat berechnen mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
GETFIRSTOFNEXTMONTH(Date) \@ Format Return: Date |
First day of next month: The first day of the next month of a given date is output in the desired format. Parameters: Date See requirements above Format Has to be a valid syntax for date formatting Example: |
GETFIRSTOFNEXTMONTH_VD(VDatum) \@ Format Rückgabe: Datum |
Erster Tag des nächsten Monats berechnen mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
GETFIRSTOFQUARTER(Date) \@ Format Return: Date |
First day of the quarter: The first day of the quarter of a given date is output in the desired format. Parameters: Date See requirements above Format Has to be a valid syntax for date formatting Example: |
GETFIRSTOFQUARTER_VD(VDatum) \@ Format Rückgabe: Datum |
Erster Tag des Quartals berechnen mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
GETLASTOFMONTH(Date) \@ Format Return: Date |
Last day of the month: The last day of the month of a given date is output in the desired format. Parameters: Date See requirements above Format Has to be a valid syntax for date formatting Example: |
GETLASTOFMONTH_VD(VDatum) \@ Format Rückgabe: Datum |
Letzter Tag des Monats berechnen mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
GETLASTOFLASTMONTH(Date) \@ Format Return: Date |
Last day of last month: The last day of the previous month of a specified date is output in the desired format. Parameters: Date See requirements above Format Has to be a valid syntax for date formatting Example: |
GETLASTOFLASTMONTH_VD(VDatum) \@ Format Rückgabe: Datum |
Letzter Tag des letzten Monats berechnen mit Valutadatum: Datumsvariablen vom Typ Valutadatum werden immer mit 30 Tagen
im Monat berechnet. Beispiel: |
GETLASTOFQUARTER(Date) \@ Format Return: Date |
Last day of the quarter: The last day of the quarter of a specified date is output in the desired format. Parameters: Date See requirements above Format Has to be a valid syntax for date formatting Example: |
Rules for processing text and date functions
Processing variables from the data supplyWithin a text or date function the name of a variable from the data supply can be used to process the content of this variable.
Example1:
{ SET myVar " My content from the data supply " }
{= LEFT(myVar; 4) }
Result: My
The content of the variable myVar may contain any characters, including special
characters such as quotation marks, semicolons, commas, brackets, etc.
Example2:
To be able to correctly process special characters that would otherwise be interpreted by RTF processing, the following procedure is recommended:
{ SET COMMA "," }
{ = SUBSTITUTE("123.45"; "."; COMMA; "1") }
Result: 123,45
The special character is assigned to a variable by the SET command, which can then be used in the SUBSTITUTE command.
Example3:
{ SET myDate "15.02.2015" }
{= ADDDAYS(myDate, 14)\@ "tt.MM.jjjj }Result: 01.03.2015
To process text or date functions concatenated, i.e. to continue working within a text/date function with the result of another text/date function, the detour via variables is necessary.
Example:
{SET a " abc "}
{SET b { = TRIM (a)} }
{ = LEFT(b;2)}
Result: ab
Here b is first assigned the value abc (the blanks are removed by the TRIM
function). Then b is passed to the LEFT function.