Use Google to find help fast. For example, search on "xpressdox choosefromlist".

The Script Feature

The Script Feature

The <<Script()>> command enables the template author to give  a name to a chunk of text, and to use that chunk repeatedly in a template.

The chunk of text can consist of from a few words to one or more paragraphs.  This named chunk can then be inserted into the document at a number of places using the <<UseScript()>> command.

Text only

An example might be the set of commands which construct a person’s name with the correct number of spaces depending on whether the first name and middle initial are known or not:

<<If(FirstName != ”)>><<FirstName>> <<If(Initial != ”)>><<Initial>> <<End()>><<End()>><<Surname>>

Those few commands will insert the Surname, preceded by FirstName and Initial, each followed by a space, but the spaces are only inserted if the FirstName and Initial have a non-empty value.  That way around, when the FirstName and/or Initial are unknown (i.e. empty), you don’t end up having extra spaces in front of Surname.

This sequence of commands is likely to be needed in a number of places in the template.  This could be achieved by copy-and-paste.  But then, if there’s a mistake, or a need to change for some other reason, then all the places where the text was copied to will need to change.  The <<Script()>> command helps here, because when a change is needed, it is only be necessary to change the Script, and all the places where the script is used will automatically change.

Here’s how it would look:

<<Script(PartyName)>><<If(FirstName != '')>><<FirstName>> <<If(Initial != '')>><<Initial>> <<End()>><<End()>><<Surname>><<ScriptEnd()>>

The name of the party is <<UseScript(PartyName)>>.

<<UseScript(PartyName)>> is required to sign here: …

Paragraphs

Scripts can include one or more paragraphs.  When the script content is included into the template, the template author can specify whether the formatting of the original paragraph or that of the destination paragraph must be applied.  This is done in the second parameter of the <<UseScript()>>command.  This second parameter is exactly the same as the second parameter passed to <<IncludeTemplate()>> and <<BaseTemplate()>> commands, except that Source has no meaning in this context.
Here follows an example of a multi-paragraph script:

<<Script(Parts)>>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.

Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus.

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.
<<ScriptEnd()>>



1. Cras faucibus condimentum odio. Sed ac ligula. Aliquam at eros.
2. Etiam at ligula et tellus ullamcorper ultrices. In fermentum, lorem non cursus porttitor, diam urna accumsan lacus, sed interdum wisi nibh nec nisl. Ut tincidunt volutpat urna.
3. Mauris eleifend nulla eget mauris. Sed cursus quam id felis. Curabitur posuere quam vel nibh.
4. <<UseScript(Parts,Paragraph)>>

The formatting instruction Paragraph (second parameter of the <<UseScript()>> command) means that the paragraphs of the script content must be formatted according to the paragraph in which the <<UseScript()>> is coded. In this example, it means that the paragraphs of the script content must be numbered – i.e they will look like:

4. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.
5. Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus.
6. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.

Leave a Reply