Capture data in a multi line field
You may not want to have to define 3 or 4 or some maximum number of address line data elements, and have the user capture them one at a time, and still provide conditional formatting logic to suppress any empty data elements.
The CaptureAsLongText command
XpressDox document assembly supports this by the concept of long text fields. The command
«CaptureAsLongText(Address,4)» will cause XpressDox to provide a 4-line text box in the data capture interview when the template is run. The lines of the address are then typed in by the user one per line (pressing the Enter key at the end of each line).
There is a quirk (or special feature) to this, though, and that is that the
«CaptureAsLongText» command does exactly and only what it says – it captures the data element as long text.
What it does not do is cause the data element to be inserted into the document. This is because there are three ways in which the data element can be included in the document:
«Address» will cause the lines of the ‘Address’ to be included in one line. For example, the address captured as:
123 Long Street
would appear as:
123 Long Street Winelands Cape Town
in the merged document.
The InsertFormattedText command
«InsertFormattedText(Address)» will cause the ‘Address’ to be formatted in the merged document with each line of ‘Address’ on its own line in the merged document, just as it was entered by the user in the data capture dialog.
With XpressDox version 4 and later, there is an extra (optional) parameter, being Paragraph or Lines. Paragraph will cause each line in ‘Address’ to appear in its own paragraph, whereas Lines (which is the default) puts line breaks between each line.
The reason for the command being
«InsertFormattedText» and not something like
«InsertMultiLine» is that the text captured inside a Long Text text box need not actually contain more than one line, but can be formatted with bold, italic and underline. This is done by using *[for bold]*, /[for italic]/ and -[for underline]-. Otherwise, select the text to be styled, and press <Ctrl b> for bold, <Ctrl i> for italic and <Ctrl u> to underline the selected text.
The InsertUnformattedLongText command
«InsertUnformattedLongText(Address,', ')» will cause the Address data element to be inserted with the lines separated with a comma-space (the second parameter of the function). In this context the
" referred to are those which the user has entered using the Enter key. In other words, if the Address has more than one line just because the text has wrapped onto a new line by reason of its length, then those lines are not recognised by the InsertUnformattedLongText command.
Multiple fields for one address
There may of course be instances (connecting to a database for example) where data is captured across multiple fields. This article provides several examples on the use of Scripts for printing addresses which have come from multiple fields into one line.