ReportWorkshop Overview | Template syntax | Variables

<< Click to display table of contents >>

ReportWorkshop Overview | Template syntax | Variables

See the topic about fields in templates for a general description of the syntax.

Syntax

<variable> ::= [']%<variable name>['][ <variable type>][ "<format>"]

A variable name (including the starting '%' character) may be enclosed in single quotes. These single quotes are necessary, if it contains space characters.

<variable type> ::= object

<format> – see variable format strings sections below.

Variable names are case insensitive.

About variables

Variables are defined in string lists of the whole report and of report tables.

When evaluating a variable, the report generator tries to find it to the most nested table, then (if not found) in the table containing this table, and so on. Finally, it searches in the global report variables.

The report table's variables are used when:

when processing content of this table's cells while applying row generation rules;

when processing this table's cells' data query strings.

They are not used:

when processing data query strings belonging to this table's row generation rules,

when processing this table's hint (tool tip).

when processing content of this table's cells that do no belong to any row generation rule and do not have a data query.

(in these cases, you can use only variables of parent tables and global report variables).

Variables are stored in a string list. Each string in this list must have the syntax:

<variable name>=<variable value>

Variable objects

It is possible that a string list item has an associated object. The variable string lists own their objects, so objects are freed when the lists are cleared or destroyed, so do not free these objects yourself.

If the field type "object" is specified, this object is inserted instead of <variable value>.

The current version of Report Workshop supports only one type of objects: an image (of a class inherited from TGraphic, such as TBitmap or TPngImage).

This feature can be used to generate pictures basing on data returned for a data query in OnProcessRecord event.

Variable format strings

Read the topic about format strings.

Variables can use format strings for strings and for images.

Use

Variables can be used:

to insert their value or object in text of templates;

to insert their value in strings (such as data queries or hyperlink targets);

as parameters of If, IfDef, IfNDef commands;

in expressions.

Examples

Example 1

Let the report has the following item in its variables:

phone2="Work phone"

The code

{%phone2}

inserts

Work phone

Example 2

Let the report has the following item in its variables:

barcode=

and this line has an associated TBitmap object

The code

{%barcode object}

inserts this bitmap in a document.

Example 3

Let the report has the following item in its variables:

fullreport=yes

And the following data fields are defined: name, address, phone

The code

Name: {name}
{$IF %fullreport="yes"}
Address: {address}
Phone: {phone}
{$ENDIF}

generates the output like:

Name: John Smith
Address: 123 Way, Nethercity
Phone: 123456