The countwords function

Description

The countwords function accepts up to two of the parameters described below (the last parameter is optional), and returns a value of type integer type, which is equal to the number of words in the first parameter. The term word is used to mean a group of contiguous characters, seperated by another group of characters called deliminators.

Parameters

  1. The first parameter (S) is an expression of type string or type char, and contains the words to be counted.
  2. The second parameter (D) is an expression of type string or type char, and contains the delimintors used to seperate words. If D is not present then the default deliminators (i.e. SPACE, TAB, RETURN, and LINEFEED) are used.

Example

   countwords('example')             returns  1
   countwords('this is an example')  returns  4

Portability

Operating Systems: All
Standard Pascal: No