tologo Logic and syntax of Templates

Top  Previous  Next

Variables

All variables and commands can be identified by \ (backslash) symbol 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)\

 

Data Scan commands

Another of RTF templates is Data Scan commands. These are used to create tables in which number of rows is determined by the number of records in database.

example How to:

1. Begin by entering \scan(dtLinkJobs)\ command. This must not necessarily be dtLinkJobs, depending on the template, this can be:

\scan(dtLinkJobs)\ — in invoices, templates, to display jobs included in invoice.
\scan(dtLinkInvoices)\ — in payment templates to display invoices linked to the payment.
\scan(dtLinkPayments)\ — in invoice templates to indicate linked sums.

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

3. Insert one row of data-columns after \scanentry\. Every variable in table must be preceeded with dtlink commfnd. For instance if the table begins with \scan(dtLinkJobs)\, each variable must have this link included: \dtLinkJobs:JOB_NAME\, \dtLinkJobs:COMPLETED\, and so on.

4. Insert \endscan\ after data-columns.

_bm3 Note: Use noeof to hide table's header and footer if the table body appears to be empty. For instance, if your invoice includes only jobs and no expenses, the header and footer for expenses will not be saved/printed.

 

Example:

table1

Command \scan(dtLinkJobs)\ will make the parser 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.

Text between \scan(dtLinkJobs)\ command and \scanentry\ command is table header.

Text between \scanfooter\ and \endscan\ commands will be considered table footer and will only be displayed once at the end of this table.

Text between \scanentry\ and \scanfooter\ commands is table "body". It includes variables from columns which must be listed in the table. In example above these are:

\dtLinkJobs:PO\ – Client PO Number.
\dtLinkJobs:COMPLETED\ – Date of job delivery.
\dtLinkJobs:JOB_NAME\ – Name of the job.
\dtLinkJobs:SERVICE\ – Service provided.

 

Condition checking

This allows the template to react to certain varying conditions and produce output suitable to each of possible conditions. The logic is the following \IF(condition)\ Reaction \ENDIF\.

Example:

If Discount 1 is applied, display discount name, discount value and subtotal. The code is as follows:

\IF(DISCOUNT1)\

\DISCOUNT1NAME\: \DISCOUNT1VALUE\

Subtotal: \AFTERDISCOUNT1\\endif\

This will make the template check if discount 1 is applied, and if so — display data between \IF(...)\ and \ENDIF\ commands.

DISCOUNT1 is a logical variable, i.e. it can have one of two values: either true or false. In this particular case, TO3000, Version 9.0 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.