$SubCnt: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 2: Line 2:
<span class="pageSubtitle"><section begin="desc" />Count occurrences of one string in another<section end="desc" /></span>
<span class="pageSubtitle"><section begin="desc" />Count occurrences of one string in another<section end="desc" /></span>


<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $SubCnt function is [[to be entered]].</p>
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no OO equivalent for the $SubCnt function.</p>


This function counts the occurrences of one string in another.  
This function counts the occurrences of one string in another.  
Line 11: Line 11:


The second argument is another arbitrary string.
The second argument is another arbitrary string.
==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %COUNT = $SubCnt(string, substring)
<p class="syntax"><section begin="syntax" /> %COUNT = $SubCnt(string, substring)
Line 17: Line 18:
</p>
</p>
<p class="caption">%COUNT is the count of occurrences of '''substring''' in '''string'''.</p>
<p class="caption">%COUNT is the count of occurrences of '''substring''' in '''string'''.</p>
For example
For example
<p class="code"> %JUNK = $SubCnt('ABCDABAB', 'AB')
<p class="code"> %JUNK = $SubCnt('ABCDABAB', 'AB')
</p>
</p>
would set %JUNK to 3 and
would set %JUNK to 3 and
<p class="code"> %JUNK = $SubCnt('WE HAVE WAITED LONG ENOUGH', -
<p class="code"> %JUNK = $SubCnt('WE HAVE WAITED LONG ENOUGH', -
  'WEHAVE')
  'WEHAVE')
</p>
</p>
would set %JUNK to 0 and
would set %JUNK to 0 and
<p class="code"> %JUNK = $SubCnt('WE HAVE WAITED LONG ENOUGH', 'E')
<p class="code"> %JUNK = $SubCnt('WE HAVE WAITED LONG ENOUGH', 'E')
</p>
</p>
would set %JUNK to 4.
would set %JUNK to 4.
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[Sirius functions]]</li>
Line 41: Line 49:
<p class="caption">Products authorizing $SubCnt
<p class="caption">Products authorizing $SubCnt
</p>
</p>


[[Category:$Functions|$SubCnt]]
[[Category:$Functions|$SubCnt]]

Revision as of 20:19, 8 February 2011

<section begin="desc" />Count occurrences of one string in another<section end="desc" />

Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no OO equivalent for the $SubCnt function.

This function counts the occurrences of one string in another.

The $SubCnt function accepts two arguments and returns a numeric result that is the count of occurrences of the second argument string in the first argument string.

The first argument is an arbitrary string.

The second argument is another arbitrary string.

Syntax

<section begin="syntax" /> %COUNT = $SubCnt(string, substring) <section end="syntax" />

$SubCnt Function

%COUNT is the count of occurrences of substring in string.

For example

%JUNK = $SubCnt('ABCDABAB', 'AB')

would set %JUNK to 3 and

%JUNK = $SubCnt('WE HAVE WAITED LONG ENOUGH', - 'WEHAVE')

would set %JUNK to 0 and

%JUNK = $SubCnt('WE HAVE WAITED LONG ENOUGH', 'E')

would set %JUNK to 4.

Products authorizing $SubCnt