RepeatWhile – XpressDox

Repeating information which is not in the form of repeating data in XML (i.e. multiple same-named XML elements) can be handled using the RepeatWhile command.

An example of the kind of repeating data that would need a RepeatWhile would be a data element that contains a comma-delimited list of directors of a company.  If the requirement is to list the directors each on their own line, then the following code would achieve this:

«SetVr(‘List’,concat(Directors,‘,’))»«Comment(make sure there’s a trailing comma otherwise the last substring-before doesn’t work)»

«RepeatWhile(GetV(‘List’) != ‘’)»

«substring-before(GetV(‘List’),‘,’)»«Comment(this inserts the name at the front of the list into the merged document)»

«SetVr(‘List’,substring-after(GetV(‘List’),‘,’))»«Comment(removes the name at the front of the list)»

«End(Repeat)»

Note that this feature is available only in Version 4 and later of XpressDox.