Related topics:


Tutorial Videos

Tutorial videos are available here.

Knowledge Base

Visit our User Forum for discussions & solutions

What is the difference between Commands and Functions

Throughout the XpressDox documentation, reference is made to Commands and also to Functions.  Syntactically commands and functions appear the same, but their functionality is different and in some cases this difference is important.

A rule of thumb for distinguishing commands from functions is that commands are used for global layout of text (e.g. ForEach, If, IncludeTemplate) and also to direct the construction of the data capture interview (e.g. Caption, ChooseFromList, etc).  Functions manipulate the contents of data elements and variables to produce a result that gets inserted into the document (e.g. FormatNumber, FormatDate, ToUpper).

The most important reason to know the difference between a command and a function, is that function calls can be nested, i.e. the value sent to a function can be the result of another function, for example:

The price is $«FormatNumber(Price)» which, less a 10% discount becomes $«FormatNumber(round(RenderAsNumeric(Price) * 0.9))».

As with most things, there are exceptions:

1. List  and Ordinal are commands, even though they insert the values into the merged document.

2. SetV, SaveV and CreateDataElement are functions.  They do insert values into the document, but the value they insert is an empty string.

More information on syntax in XpressDox is available at Notes on XpressDox syntax.