IsOneOf (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
 
(30 intermediate revisions by 6 users not shown)
Line 1: Line 1:
This [[Intrinsic classes|intrinsic]] function returns a Boolean value that indicates whether the method object
{{Template:String:IsOneOf subtitle}}
string is matched by one of the strings in an input list of strings.                                         
The input list of strings is concatenated in a single delimited longstring argument to the method.
A returned value of ''''True'''' signals a successful match.                                                 
                                                                                                             
The IsOneOf function is available as of version 7.3 of the [[Sirius Mods]].                                   
===IsOneOf syntax===                                                                                         
  %bool = string:IsOneOf(stringSet)                                                                         
===Syntax Terms===                                                                                           
<dl>                                                                                                         
<dt>%bool                                                                                                     
<dd>An enumeration object of type Boolean to contain the returned value of IsOneOf.                           
<dt>string                                                                                                   
<dd>The string to which the method is applied, the maximum length of which is 255 bytes.                     
<dt>stringSet                                                                                                 
<dd>A longstring that contains a delimited set of potential matching strings                                 
for the method object string.
The strings in ''stringSet'' are separated by a separator character,                     
which must be indicated by the first character of the argument.                           
The separator must be non-alphanumeric.                                                   
The format of ''stringSet'' is therefore                                                 
''separatorString1[separatorString2]...''.                                               
                                                                                         
</dl>                                                                                     
===Usage Notes===                                                                         
*The ''stringSet'' argument must be non-null or the request is cancelled.                 
===Examples===                                                                           
                                                                                         
The following are IsOneOf sample statements:                                             
    %str is longstring                                                                   
    %str = 'bleh'                                                                         
    [[Intrinsic classes#printtext|printText]] {~} = '{%str:isOneOf('/blah/bleh/blih')}'           
    printText {~} = '{%str:isOneOf(',blah,bleh,blih')}'                                   
    printText {~} = '{%str:isOneOf('/blah/blh/blih')}'                                   
                                                                                         
The results are respectively:                                                             
    %str:isOneOf('/blah/bleh/blih') = True                                               
    %str:isOneOf(',blah,bleh,blih') = True                                               
    %str:isOneOf('/blah/blh/blih') = False


===See also===                                                                                       
<var>IsOneOf</var> is an [[Intrinsic classes|intrinsic]] function that returns a <var>Boolean</var> value that indicates whether the method object string is matched by one of the strings in an input <var class="term">list</var> of strings.  The input <var class="term">list</var> of strings is concatenated in a single delimited string argument to the method.  A returned value of <code>True</code> signals a successful match.
[[List of Intrinsic String Methods]]


[[Category:Intrinsic String methods|IsOneOf function]]
==Syntax==
[[Category:Intrinsic methods]]
{{Template:String:IsOneOf syntax}}
[[Category:System methods]]
===Syntax terms===
<table class="syntaxTable">
<tr><th>%boolean</th>
<td>An enumeration object of type <var>Boolean</var> to contain the returned value of <var>IsOneOf</var>.</td></tr>
<tr><th>string</th>
<td>The string to which the method is applied, the maximum length of which is 255 bytes.</td></tr>
<tr><th>list</th>
<td>A string that contains a delimited set of potential matching strings for the method object <var class="term">string</var>. The strings in <var class="term">list</var> are separated by a separator character, which must be indicated by the first character of the argument. The separator must be non-alphanumeric. The format of <var class="term">list</var> is therefore:
<p class="syntax"><i>separatorString1[separatorString2][separatorString3]...</i></p></td></tr>
</table>
 
==Usage notes==
<ul><li>The <var class="term">list</var> argument must be non-null or the request is cancelled.
<li><var>IsOneOf</var> is available as of <var class="product">[[Sirius Mods|Sirius Mods]]</var> version 7.3.
<li>If the method object <var class="term">string</var> is known to be a single character, then a slightly more efficient approach is to use <var>[[PositionIn (String function)|PositionIn]]</var>, for example:
<p class="code">%c is string len 1
...
if %c:PositionIn('0123456789') then
  * Handle numeric digit:
  ...
end if
</p>
</ul>
 
==Examples==
The following are <var>IsOneOf</var> sample statements:
<p class="code">%str is longstring
%str = 'bleh'
[[PrintText statement|printText]] {~} = '{%str:isOneOf('/blah/bleh/blih')}'
printText {~} = '{%str:isOneOf(',blah,bleh,blih')}'
printText {~} = '{%str:isOneOf('/blah/blh/blih')}'
</p>
The results are respectively:
<p class="output">%str:isOneOf('/blah/bleh/blih') = True
%str:isOneOf(',blah,bleh,blih') = True
%str:isOneOf('/blah/blh/blih') = False
</p>
 
[[Category:String methods|IsOneOf function]]
 
==See also==
{{Template:String:IsOneOf footer}}

Latest revision as of 18:29, 4 February 2013

Is the method object string matched by any of the strings in the input list? (String class)


IsOneOf is an intrinsic function that returns a Boolean value that indicates whether the method object string is matched by one of the strings in an input list of strings. The input list of strings is concatenated in a single delimited string argument to the method. A returned value of True signals a successful match.

Syntax

%boolean = string:IsOneOf( list)

Syntax terms

%boolean An enumeration object of type Boolean to contain the returned value of IsOneOf.
string The string to which the method is applied, the maximum length of which is 255 bytes.
list A string that contains a delimited set of potential matching strings for the method object string. The strings in list are separated by a separator character, which must be indicated by the first character of the argument. The separator must be non-alphanumeric. The format of list is therefore:

separatorString1[separatorString2][separatorString3]...

Usage notes

  • The list argument must be non-null or the request is cancelled.
  • IsOneOf is available as of Sirius Mods version 7.3.
  • If the method object string is known to be a single character, then a slightly more efficient approach is to use PositionIn, for example:

    %c is string len 1 ... if %c:PositionIn('0123456789') then * Handle numeric digit: ... end if

Examples

The following are IsOneOf sample statements:

%str is longstring %str = 'bleh' printText {~} = '{%str:isOneOf('/blah/bleh/blih')}' printText {~} = '{%str:isOneOf(',blah,bleh,blih')}' printText {~} = '{%str:isOneOf('/blah/blh/blih')}'

The results are respectively:

%str:isOneOf('/blah/bleh/blih') = True %str:isOneOf(',blah,bleh,blih') = True %str:isOneOf('/blah/blh/blih') = False

See also