$Word: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Mlarocca moved page $WORD to $Word: Lower case change)
m (misc cleanup)
 
Line 1: Line 1:
<p>The $WORD function searches a string from the left for a complete word and returns the nth word in a specified string, delimited by a blank or optionally specified character.</p>
<p>
<b>Syntax</b>
The <var>$Word</var> function searches a string from the left for a complete word and returns the nth word in a specified string, delimited by a blank or optionally specified character.</p>
<p>The format of the $WORD function is:</p>
 
<p class="code">$WORD('inputstring',['delimiter'],<var>[</var>n<var>]</var>)
==Syntax==
<p>
The format of the <var>$Word</var> function is:</p>
<p class="syntax">$Word('inputstring',['delimiter'],<var>[</var>n<var>]</var>)
</p>
</p>
<p>where:</p>
<p>Where:</p>
<ul>
<ul>
<li>inputstring is the input from which the specified word is to be extracted. inputstring can be a quoted literal or a %variable.</li>
<li>inputstring is the input from which the specified word is to be extracted. inputstring can be a quoted literal or a %variable.</li>
</li>
 
<li>delimiter is an optional quoted character or string to be used as a delimiter in parsing the input string into words. If delimiter is not specified, it defaults to a blank space. If delimiter consists of more than one character, <var class="product">Model&nbsp;204</var> uses the first character in the string as the delimiter.</li>
<li>delimiter is an optional quoted character or string to be used as a delimiter in parsing the input string into words. If delimiter is not specified, it defaults to a blank space. If delimiter consists of more than one character, <var class="product">Model&nbsp;204</var> uses the first character in the string as the delimiter.</li>
</li>
 
<li>n is the ordinal number of the word to be extracted. $WORD returns a null string under any of the following conditions:</li>
<li>n is the ordinal number of the word to be extracted. <var>$Word</var> returns a null string under any of the following conditions:
</li>
<ul>
<li>n is not specified</li>
<li>n is less than 1 (0 or negative)</li>
<li>n is greater than the number of words in inputstring</li>
<li>The commas which separate the three arguments are required, even if delimiter is not specified.</li>
</ul></li>
</ul>
</ul>
<p>n is not specified</p>
 
<p>n is less than 1 (0 or negative)</p>
==Usage==
<p>n is greater than the number of words in inputstring</p>
<p>
<p>The commas which separate the three arguments are required, even if delimiter is not specified.</p>
Null values between delimiters are not considered words. For example: </p>
<b>Usage</b>
<p class="code">$word('=ABCD==D=XXX','=',2)
<p>Null values between delimiters are not considered words. For example, </p>
<p class="code">$WORD('=ABCD==D=XXX','=',2)
</p>
</p>
<p>returns D as the second word, not a null value.</p>
<p>
<b>Examples</b>
Here <var>$Word</var> returns <code>D</code> as the second word, not a null value.</p>
<p>The following function returns the third word in the string, "THE", when a single space delimits a word:</p>
 
==Examples==
<p>
The following function returns the third word in the string, "THE", when a single space delimits a word:</p>
<p class="code">$WORD ('NOW IS THE TIME',,3)
<p class="code">$WORD ('NOW IS THE TIME',,3)
</p>
</p>
<p>The following function returns the second word in the string, "S THE T", where a word is composed of the characters that precede a delimiting I:</p>
<p>
The following function returns the second word in the string, "S THE T", where a word is composed of the characters that precede a delimiting I:</p>
<p class="code">$WORD ('NOW IS THE TIME','I',2)
<p class="code">$WORD ('NOW IS THE TIME','I',2)
</p>
</p>
[[Category:SOUL $functions]]
[[Category:SOUL $functions]]

Latest revision as of 20:38, 11 March 2015

The $Word function searches a string from the left for a complete word and returns the nth word in a specified string, delimited by a blank or optionally specified character.

Syntax

The format of the $Word function is:

$Word('inputstring',['delimiter'],[n])

Where:

  • inputstring is the input from which the specified word is to be extracted. inputstring can be a quoted literal or a %variable.
  • delimiter is an optional quoted character or string to be used as a delimiter in parsing the input string into words. If delimiter is not specified, it defaults to a blank space. If delimiter consists of more than one character, Model 204 uses the first character in the string as the delimiter.
  • n is the ordinal number of the word to be extracted. $Word returns a null string under any of the following conditions:
    • n is not specified
    • n is less than 1 (0 or negative)
    • n is greater than the number of words in inputstring
    • The commas which separate the three arguments are required, even if delimiter is not specified.

Usage

Null values between delimiters are not considered words. For example:

$word('=ABCD==D=XXX','=',2)

Here $Word returns D as the second word, not a null value.

Examples

The following function returns the third word in the string, "THE", when a single space delimits a word:

$WORD ('NOW IS THE TIME',,3)

The following function returns the second word in the string, "S THE T", where a word is composed of the characters that precede a delimiting I:

$WORD ('NOW IS THE TIME','I',2)