The Format Function

The Format Function

When concatenating strings together (see Concatenating Strings), it is not always easy to visualize what the end result will look like. This is especially the case when the strings being concatenated are a mixture of fixed text and values of data elements and functions.

This situation often arises when using CreateDataElement to build up a data element to be used, for example, as a file name.

The codes ‘{0}’ and ‘{1}’ are insertion point markers, and refer to the first and second insertion parameters after the format string, respectively.

You can have up to 10 insertion point markers, i.e. {0}, {1}, {2}, … {9}, as long as there is a matching parameter (after the format string) for each insertion point marker.

You can repeat an insertion point marker, which will repeat the occurrence of the inserted string, and the insertion point markers can be in any order in the format string, as long as they correspond to the position of the relevant insertion parameters.

The above is all rather complicated to specify formally, but try it and see – it’s very easy to use.