$Windex: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
Line 22: Line 22:
</p>
</p>
<p class="caption">%NUM is either a word number or 0.</p>
<p class="caption">%NUM is either a word number or 0.</p>
==Examples==
For example, this statement sets %JUNK to 3:
For example, this statement sets %JUNK to 3:
<p class="code"> %JUNK = $Windex('BOB CAROL TED ALICE', 'TED')
<p class="code">%JUNK = $Windex('BOB CAROL TED ALICE', 'TED')
</p>
</p>


This statement sets %JUNK to 0:
This statement sets %JUNK to 0:


<p class="code"> %JUNK = $Windex('BOB CAROL TED ALICE', 'ROGER')
<p class="code">%JUNK = $Windex('BOB CAROL TED ALICE', 'ROGER')
</p>
</p>


This statement sets %JUNK to 2:
This statement sets %JUNK to 2:


<p class="code"> %JUNK = $Windex('A WORD/OR TWO/BEFORE/I/GO', 'OR TWO', '/')
<p class="code">%JUNK = $Windex('A WORD/OR TWO/BEFORE/I/GO', 'OR TWO', '/')
</p>
</p>



Revision as of 19:36, 25 October 2012

Word number of first occurrence of word in phrase


Note: Most Sirius $functions have been deprecated in favor of Object Oriented methods. The recommended OO replacement function for $Windex is WordNumberIn. However, unlike $Windex, WordNumberIn is Longstring capable (like all OO methods), so do not replace WordNumberIn with $Windex. Note also that in some cases the StringTokenizer may be a better OO solution.


$Windex finds the first occurrence of a word in a phrase.

The $Windex function accepts three arguments and returns a numeric result that is the word number in the first argument string of the the second argument word.

The first argument is an arbitrary string.

The second argument is word that is to be located in the first argument. If the second argument string is not found, $Windex returns a 0.

The third argument is a delimiter that separates words in the first argument string. This is an optional argument and defaults to blank.

Syntax

<section begin="syntax" />%NUM = $Windex(string, word, delim) <section end="syntax" />

$Windex Function

%NUM is either a word number or 0.

Examples

For example, this statement sets %JUNK to 3:

%JUNK = $Windex('BOB CAROL TED ALICE', 'TED')

This statement sets %JUNK to 0:

%JUNK = $Windex('BOB CAROL TED ALICE', 'ROGER')

This statement sets %JUNK to 2:

%JUNK = $Windex('A WORD/OR TWO/BEFORE/I/GO', 'OR TWO', '/')

Products authorizing $Windex