11.04.2013 Views

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

COUNT<br />

Syntax<br />

COUNT(str.expr1, str.expr2)<br />

Description<br />

The <strong>UniBasic</strong> COUNT function returns the number of times a substring appears<br />

within a string. The string you want to search, str.expr1, must be longer than the<br />

substring str.expr2. After str.expr2 is found, the system searches the string again with<br />

the new starting point after the entire first occurrence of str.expr2. If str.expr2 is not<br />

found, the COUNT function returns 0. COUNT supports multibyte languages.<br />

Note: In BASICTYPEs P and M, after UniData finds str.expr2, it searches the string<br />

again with the new starting point after the first character of the first occurrence of<br />

str.expr2. UniData can find overlapping character strings.<br />

Parameters<br />

The following table describes each parameter of the syntax.<br />

Parameter Description<br />

Examples<br />

In the following example, the program segment searches the string STRING for the<br />

number of occurrences of the substring II. It returns this number, 2, in the variable IC.<br />

1-171 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />

str.expr1 Specifies the string to search. This string must be longer than str.expr2.<br />

str.expr2 Specifies the target string to search for and count occurrences of in str.expr1.<br />

COUNT Parameters<br />

STRING = "JAWSII,ROCKYIII,STARTREKIV"<br />

IC = COUNT(STRING,"II")

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!