basic.dcount Function/BASIC Program

basic.dcount

Command basic.dcount Function/BASIC Program
Applicable release versions: AP, R83
Category BASIC Program (486)
Description returns the number of occurrences of the delimiter specified in "string.expression2" within "string.expression1", plus one.

The difference between this function and the "count" function is that 1 is added to the result unless the string referenced in "string.expression1" is null.
Syntax dcount(string.expression1, string.expression2)
Options
Example
string = "a" : char(254) : "b" : char(254) : "c"
how.many = dcount(string,char(254))
for amc = 1 to how.many
  crt string<amc>
next amc

"how.many" contains the number of attributes in "string". 
In this example, there are 3 and each attribute is displayed to the terminal on 
a separate line.

input sentence
sentence = trim(sentence)
maxwords = dcount(sentence,' ')
for wordcnt = 1 to maxwords
  print field(sentence,' ',wordcnt)
next wordcnt

In this example, "sentence" is entered from the keyboard. The string 
in "sentence" is trimmed of excess blanks, and the number of words 
delimited by spaces is counted using "dcount". The words are then 
printed on separate lines.
Purpose
Related ue.201e
basic.functions
basic.count