Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ParameterDescription
source_stringIdentifies the string to search for in search_string. Can be a literal string, expression, constant, or variable.
search_stringIdentifies the string to search for in source_string. search_string may be a literal string, expression, constant, or variable.

If search_string does not appear in source_string, or if search_string is null, a 0 (zero) will be returned.

The Count() and DCount() functions are usually used to determine the size of a dynamic array. They actually have a more general purpose use, because the search string can be any string used as a delimiter, even multiple character strings.

Note: To count the number of values in a dynamic array, you need to account for the possibility that the array has one value, with no delimiter. The count() function in this case will return 0 because there is no delimiter in the string. To return the correct answer (1), you need to add the boolean expression ( var # ), which returns 1 if the variable contains a value but 0 if it is null. See the example below.

Note: If you use dcountDCount() to count the number of values in a dynamic array, you do not need to add the boolean expression because dcountDCount() returns the proper result (1) if the array has one value with no delimiter.

See Also

dcountDCount()

Example

Code Block
* count the number of items in an @fm-delimited list
cnt = count(List, @fm) + (List# '')
* this is equivalent to:
declare function dcount
cnt = dcount(List, @fm)