tologo Logic of Templates

Top  Previous  Next

This overview introduces you to three concepts used in Translation Office 3000 V8 templates:

variables;
data scan commands
condition commands.

_bm2

 

Variables

All variables and commands are marked by \ (backslash) sign in the beginning and in the end. In example below you can see \CLIENT_NAME\, \CLIENT_STREET1\ and \CLIENT_PHONE1\ variables:

To: \CLIENT_NAME\

Address: \CLIENT_STREET1\

Phone: \CLIENT_PHONE1\

When you use this template by clicking on Save or Print in some dialog box, \CLIENT_NAME\ variable will be replaced by name of currently selected Client, \CLIENT_STREET1\ - by Client’s Street Address and \CLIENT_PHONE1\ - by Client’s Phone Number. The final output will look like this:

To: XYZ Company

Address: Elm street, 1

Phone: +1 212 898 11 31

_bm3 Note: Numerical values sometimes are surrounded by fnum command. This command simply tells the parser to round up the value to specified number of digits after decimal point (2 digits in the example below):

Job Total:

\fnum(dtLinkJobs:TOTAL, 2)\

 

_bm2

 

Data Scan commands

Another concept you need to understand while working with templates is Data Scan commands:

table1

In the example above \scan(dtLinkJobs)\ means that, during saving or printing operation parser will scan (go from first record to the last one) all selected data in Jobs table (in this particular case all Jobs included in the Invoice) and output them to file or printer.

Everything between \scan(dtLinkJobs)\ command and \scanentry\ command constitutes header and will be saved (or printed) only once per data table.

Everything between \scanfooter\ and \endscan\ commands is recognized as footer and also saved (or printed) only once per data table.

Body of table is contained between \scanentry\ and \scanfooter\ commands. It includes variables from columns you would like to be listed in the table. In example above these are:

\dtLinkJobs:PO\ - PO Number.

\dtLinkJobs:COMPLETED\ - Date of Job Delivery.

\dtLinkJobs:JOB_NAME\ - Name of the Job.

\dtLinkJobs:SERVICE\ - Service provided.

 

dtLinkJobs:” – prefix. Not valid without column name. Add separator (“:” - semicolon) before column names. Column names are variables described in next chapters.

\scan(dtLinkJobs)\” – command to scan table with Jobs. Put before table with Jobs.

\scanentry\” – start of scan.

 

Insert table header between \scan(dtLinkJobs)\ and \scanentry\.

Insert data-columns only after \scanentry\.

Insert \endscan\ after data-columns.

 

exampleExample of data-columns:

Payments received:

table2

_bm3 Note: You can include special noeof parameter to scan command. With noeof parameter, when data table is empty, header and footer are not printed. For instance, in the example above, if your Invoice includes only Jobs and no expenses, the header and footer for Expenses will not be saved/printed. Such algorithm prevents producing unnecessary empty tables in the documents.

 

_bm2

 

Condition checking

Third and last concept used in Templates is condition checking:

\IF(DISCOUNT1)\

\DISCOUNT1NAME\: \DISCOUNT1VALUE\

Subtotal: \AFTERDISCOUNT1\\endif\

 

DISCOUNT1 is a logical variable, i.e. it can have one of two values: either true or false. In this particular case, Translation Office 3000 V8 sets DISCOUNT1 into true if first discount is present and into false, if there is no first discount.

When \IF(DISCOUNT1)\ is encountered in template, parser checks DISCOUNT1 logical value, and if it is true, runs the code below this command, until \endif\ is encountered, which instructs parser to stop. If DISCOUNT1 is false, everything until \endif\ command is skipped.

In this particular case, without \IF(DISCOUNT1)\ command, the parser would output empty string with: and empty Subtotal: in cases when there would not be discount. But with \IF(DISCOUNT1)\ command, in such cases above block is skipped in its entirety.

 

_bm95

 

In other topics of Templates chapter you can find the list of common template variables, available in all parts of Translation Office 3000 V8, and specific variables, which have limited availability.