exist

The exist function returns a nonzero (true) value if there is data in a specified field in internal storage. If there is not data in the specified field, this function returns a zero (false) value. This function is typically used as part of a condition.

All modes of operation are exercised by SWIFT MX and FIN maps in the existing extended rule. FIN maps reference the traditional usage ($group.#field) of the exist function while the MX maps reference only the group name ($group).

Note: The group name only usage is reserved for the XML syntax only, because of how the blocks are inserted into the map structure during the compilation process to handle the XML start and end tags in an XML document.

The exist function accepts a block reference denoted with a % prefix, as well as a group reference denoted with the $ prefix. The group reference supports a scenario in which an element was supplied in the input file but none of its conditional children existed. Instead of using variables to test for the condition of a parent element (parentNode) you can just use the group reference (only for XML). If you wanted to check for the existence of the parentNode in this scenario, you can add a flag to the extended rule of the parentNode to determine this condition if the child fields are missing. For example:


integer p;
p = exist($parentNode);

Syntax

Use this syntax:


if exist($GROUP_NAME[index][index][index]. #FIELD_NAME) then

Example

An example of this function follows:



if exist($GROUPNAME[0][1][1].#FIELDNAME) then
//Return a non-zero value if the condition is true (data is present in
//the specified instance of the FIELDNAME field). A zero value is
//returned if the condition is false (no data is present in the
//specified instance of the FIELDNAME field).