Search

CommasAndList – XpressDox

This function is very similar to the List command. The difference is that List operates on repeated data elements (e.g. the names of parties), whereas CommasAndList operates on a list which is contained either in one data element, or, more typically, in a variable constructed out of other values.

Suppose a variable named ‘JoinedValues’ is constructed earlier in the document from other values, where the joined items are separated by the character ‘/’. The following example will present those joined values with the ‘/’ delimiter being replaced by ‘, ‘ in all cases except for the last, which is replaced by ‘ and ‘.

«CommasAndList(GetV('JoinedValues'),'/',', ',' and ')»

If the variable JoinedValues looked like ‘Sunday//Tuesday/Wednesday//Friday/Saturday’ then the above function would output:

Sunday,Tuesday,Wednesday,Friday and Saturday

A special feature of this function is that empty values (e.g. in the above example, where two ‘/’ characters appear together as ‘//’) are ignored.