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

Concatenating strings

Concatenating strings

A pluralising example

Suppose you have a need to create an XpressDox Variable which will contain either a singular or plural from a data element. Using the example of a Will in Working with repeated elements, we might want to use the word “child” or “children” in many places, and not want to use <<When(count(Child)…>> everywhere, but rather use a variable, e.g. <<GetV(‘childword’)>>.

There are a number of ways of setting the variable “childword” to the required value, but here is one that makes use of the concat function inside a <<SetV>> to concatenate the suffix “ren” to the word “child” when the number of Child data elements is greater than one:

<<SetV('childword','child')>>
<<If(count(Child) > 1)>>
<<SetV('childword',concat(GetV('childword'),'ren'))>>
<<End()>>

Thereafter any execution of <<GetV('childword')>> will put the correct variation of “child” or “children” into the merged document.

A file path example

Another use of the concat function would be to construct a file path given its constitutents. For example, suppose the drive, folder and file name are located in three separate data elements. Setting a variable to contain the full file path would look like this:
<<SetV('FullFilePath',concat(Drive,'\',Folder,'\',FileName))>>

Leave a Reply