$SubCnt: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 5: Line 5:


This function counts the occurrences of one string in another.  
This function counts the occurrences of one string in another.  
The <var>$SubCnt</var> 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==
==Syntax==
Line 16: Line 10:
<section end="syntax" /></p>
<section end="syntax" /></p>


<p class="caption">%count is the count of occurrences of '''substring''' in '''string'''.</p>
===Syntax terms===
<table class="syntaxTable">
<tr><th>%count</th>
<td>The count of occurrences of <var class="term">substring</var> in <var class="term">string</var>.</td></tr>


For example
<tr><th>string</th>
<td>An arbitrary string. </td></tr>


<p class="code"> %JUNK = $SubCnt('ABCDABAB', 'AB')
<tr><th>substring</th>
<td>Another arbitrary string.</td></tr>
</table>
 
==Examples==
The following statement would set %JUNK to 3:
<p class="code">%JUNK = $SubCnt('ABCDABAB', 'AB')
</p>
</p>


would set %JUNK to 3 and
This statement would set %JUNK to 0:
 
<p class="code">%JUNK = $SubCnt('WE HAVE WAITED LONG ENOUGH', 'WEHAVE')
<p class="code"> %JUNK = $SubCnt('WE HAVE WAITED LONG ENOUGH', -
'WEHAVE')
</p>
</p>


would set %JUNK to 0 and
And this statement would set %JUNK to 4:
 
<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.


==Products authorizing $SubCnt==
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[Sirius functions]]</li>
Line 44: Line 45:
<li>[[Japanese functions]]</li>
<li>[[Japanese functions]]</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Sir2000 Field Migration Facility]]</li>
</ul>


</ul>
<p class="caption">Products authorizing $SubCnt
</p>


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

Revision as of 23:01, 24 October 2012

Count occurrences of one string in another

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.

Syntax

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

Syntax terms

%count The count of occurrences of substring in string.
string An arbitrary string.
substring Another arbitrary string.

Examples

The following statement would set %JUNK to 3:

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

This statement would set %JUNK to 0:

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

And this statement would set %JUNK to 4:

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

Products authorizing $SubCnt