$Lstr Word: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (misc cleanup)
 
(38 intermediate revisions by 4 users not shown)
Line 2: Line 2:
<span class="pageSubtitle">Return a word from a long string</span>
<span class="pageSubtitle">Return a word from a long string</span>


<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for <var>$Lstr_Word</var> is <var>[[Word (String function)|Word]]</var> (<b>except</b> that <var>Word</var> does not allow a word number argument less than 1, as does <var>$Lstr_Word</var>.) Or, you may find the features of the [[StringTokenizer class|StringTokenizer]] to be more helpful.</p>
<p class="warn"><b>Note: </b>Most SOUL $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for $Lstr_Word is <var>[[Word (String function)|Word]]</var> (<b>except</b> that <var>Word</var> does not allow a word number argument less than 1, as does $Lstr_Word.) Or, you may find the features of the [[StringTokenizer class|StringTokenizer]] to be more helpful.</p>


This function takes a longstring input and a word number and returns a longstring containing a single word. A null string is returned if the word count in the input longstring is less than the word number.  
This function takes a <var>Longstring</var> input and a word number and returns a <var>Longstring</var> containing a single word. A null string is returned if the word count in the input <var>Longstring</var> is less than the word number.  


The $Lstr_Word function accepts three arguments and returns a longstring result.
==Syntax==
<p class="syntax"><span class="term">%result</span> = $Lstr_Word(<span class="term">longstring</span>, <span class="term">n</span>, <span class="term">delims</span>)
</p>


The first argument is an arbitrary longstring. This is a required argument.  
<p><var class="term">%result</var> is  a <var>Longstring</var> that is the <var class="term">n</var>th word in the <var class="term">longstring</var> argument.</p>


The second argument is the number of the desired word. The first word in the input longstring is word 1.  
<var class="term">longstring</var> is an arbitrary <var>Longstring</var>. This is a required argument.  


The third argument is a string containing from 1 to 255 characters which are the delimiters for the longstring. This is an optional argument and defaults to a blank.
<var class="term">n</var> is the number of the desired word. The first word in the <var class="term">longstring</var> input is word 1.  


==Syntax==
<var class="term">delims</var> is a string containing from 1 to 255 characters which are the delimiters for <var class="term">longstring</var>. This is an optional argument, and it defaults to a blank.
<p class="syntax"><section begin="syntax" /> %RESULT = $Lstr_Word(longstring, n, delims)
<section end="syntax" /></p>
<p class="caption">$Lstr_Word function
</p>
<p class="caption">%RESULT is the ''n''th word in the longstring.</p>


For example
==Examples==
<p class="code"> %RES = $Lstr_Word('She sells sea-shells by the sea shore', 7)
<ol>
<li>To set <var class="term">%res</var> to "shore":
<p class="code">%res = $Lstr_Word('She sells sea-shells by the sea shore', 7)
</p>
</p>


sets %RES to "shore" and
<li>To set <var class="term">%res</var> to "sea":


<p class="code"> %RES = $Lstr_Word('She sells sea-shells by the sea shore', 7, '- ')
<p class="code">%res = $Lstr_Word('She sells sea-shells by the sea shore', 7, '- ')
</p>
</p>
 
</ol>
sets %RES to "sea".
 
$Lstr_Word is only available in <var class="product">[[Sirius Mods]]</var> Version 6.5 and later. Prior to Version 7.3 (or Version 7.1 or 7.2, with maintenance applied), if the result of $Lstr_Word was longer than 255 bytes, either the request was cancelled or the result was truncated at 255 bytes.


==See also==
==See also==
<ul>
<ul>
<li><var>[[Word (String function)|Word]]</var> - Select word from list of words
<li><var>[[Word (String function)|Word]]</var> &mdash; Select word from list of words
<li><var>[[Words (String function)|Words]]</var> - Sublist of list of words
<li><var>[[Words (String function)|Words]]</var> &mdash; Sublist of list of words
<li><var>[[WordCount (String function)|WordCount]]</var> - Count words in list
<li><var>[[WordCount (String function)|WordCount]]</var> &mdash; Count words in list
<li><var>[[WordNumberIn and WordNumberOf (String functions)|WordNumberIn and WordNumberOf]]</var> - Word number of "needle" word within "haystack" list of words
<li><var>[[WordNumberIn and WordNumberOf (String functions)|WordNumberIn and WordNumberOf]]</var> &mdash; Word number of "needle" word within "haystack" list of words
</ul>
</ul>


<p>
<p>
==Products authorizing {{PAGENAMEE}}==
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[List of $functions|Sirius functions]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Janus Open Client]]</li>
<li>[[Media:JoclrNew.pdf|Janus Open Client]]</li>
<li>[[Janus Open Server]]</li>
<li>[[Media:JosrvrNew.pdf|Janus Open Server]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Japanese functions]]</li>
<li>Japanese functions</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li>
</ul>  
</ul>  
</p>
<p class="caption">Products authorizing $Lstr_Word
</p>
</p>


[[Category:$Functions|$Lstr_Word]]
[[Category:$Functions|$Lstr_Word]]

Latest revision as of 16:50, 29 February 2016

Return a word from a long string

Note: Most SOUL $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for $Lstr_Word is Word (except that Word does not allow a word number argument less than 1, as does $Lstr_Word.) Or, you may find the features of the StringTokenizer to be more helpful.

This function takes a Longstring input and a word number and returns a Longstring containing a single word. A null string is returned if the word count in the input Longstring is less than the word number.

Syntax

%result = $Lstr_Word(longstring, n, delims)

%result is a Longstring that is the nth word in the longstring argument.

longstring is an arbitrary Longstring. This is a required argument.

n is the number of the desired word. The first word in the longstring input is word 1.

delims is a string containing from 1 to 255 characters which are the delimiters for longstring. This is an optional argument, and it defaults to a blank.

Examples

  1. To set %res to "shore":

    %res = $Lstr_Word('She sells sea-shells by the sea shore', 7)

  2. To set %res to "sea":

    %res = $Lstr_Word('She sells sea-shells by the sea shore', 7, '- ')

See also

Products authorizing $Lstr_Word