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

The Eq Function

The Eq Function

Sometimes it is necessary to compare the value of a data element to one or more fairly lengthy strings.  This can be tedious for the template author and also open to typing errors.  The Eq function is useful in this situation as the comparison can include wild card characters.  It is best described by way of example.

Suppose the data element MaritalStatus is captured and used something like this:

«ChooseFromList(MaritalStatus,Unmarried,Married with Ante-nuptial Contract,Married in Community of Property,Divorced)»

«Select()»

«Case(MaritalStatus = 'Unmarried')»not married«End()»

«Case(MaritalStatus='Married in Community of Property')»Married in COP«End()»

etc

«End()»

The second Case command in particular will require a lot of typing and the author will have to be very careful to have the correct number of spaces in the comparison and also be careful to get the case (upper or lower) correct. Using the Eq function, the second Case command would look like this:

«Case(Eq(MaritalStatus,'marr*com*prop*’)»Married in COP«End()»

The “*” wild card character essentially says “any number of characters (including no character) of any value can occur in this place”. That would mean that, for example, the above Case would also match “Married out of Community of Property”. But seeing that is not one of the options in the ChooseFromList, the match will only ever be true for “Married in Community of Property”.

Note that the comparison, besides featuring the wild card “*” is also case insensitive.

Another variation of the Eq function would be used for shortish strings where typing mistakes involving upper and lower case would be problematic.

Look at this example:

«ChooseFromList(Option,Wrapped (in Plastic),Wrapped (in Paper))»
«Select()»
«Case(Eq(Option, 'wrappedinplastic'))»Plastic«End()»
«Case(Eq(Option, 'wrappedinpaper'))»Paper«End()»
«End()»

Although this could probably be better achieved using the wild-card, this example shows that when a comparison is made where there are no wild-card characters, then the function strips out all non-alphabetic characters and compares the results in a case-insensitive manner.