Application icon

Count Items

This function will count the number of items in a field or a named variable.

The delimiter can take two forms. When String is specified, the delimiter is treated as a single item. The supplied delimiter may contain any of the escape sequences described in Escape Sequences. Note when running stepwise the delimiter is evaluated only once based on the first file's field values. Example: if the delimiter is --- a sequence of three - characters will be used to separate fields.

When Characters is specified, the delimiter is treated as a sequence of single characters, each of which will separate fields. Example: if the delimiter is ,& fields will be separated by , characters and & characters.

Regardless of the delimiter type, if it evaluates to an empty string at runtime, a default (\~) will be assumed.

Note that empty fields are counted. Example: With a delimiter of - and a source value of a--b, 3 will be returned.

The item count is returned in the specified track variable or named variable.

If a named variable is specified for the source or destination, it may contain any of the escape sequences described in Escape Sequences.

Note that by default, specifying a field when running stepwise will return the maximum item count across all selected files. If the source and destination are both not named variables, a Per file option will be displayed. When set, the per file counts will be saved as oposed to the maximum item count.

Quite often when counting items you are interested in comparing the resultant count against zero. When the Per file option is not set, you can enable the Set Action Test State based on == 0 option. When the option is enabled, the test state will be set to true if the returned count is equal to zero, otherwise it will be set to false. When the option is not enabled, the action test state is not modified.