Subset (Stringlist function): Difference between revisions
m (1 revision) |
mNo edit summary |
||
(12 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{Template:Stringlist:Subset subtitle}} | {{Template:Stringlist:Subset subtitle}} | ||
This method creates a Stringlist that is a subset of the method Stringlist. The subset is created by selecting all entries that contain a specified search string. | This method creates a <var>Stringlist</var> that is a subset of the method <var>Stringlist</var>. The subset is created by selecting all entries that contain a specified search string. | ||
==Syntax== | ==Syntax== | ||
{{Template:Stringlist:Subset syntax}} | {{Template:Stringlist:Subset syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%outlist</th> | <tr><th>%outlist</th> | ||
<td>A reference to a Stringlist which is set to the newly-created subset Stringlist.</td></tr> | <td>A reference to a <var>Stringlist</var> which is set to the newly-created subset <var>Stringlist</var>.</td></tr> | ||
<tr><th>sl</th> | <tr><th>sl</th> | ||
<td>A Stringlist object.</td></tr> | <td>A <var>Stringlist</var> object.</td></tr> | ||
<tr><th>string</th> | <tr><th>string</th> | ||
<td>The string to be located. This argument is called the search string.</td></tr> | <td>The string to be located. This argument is called the search string.</td></tr> | ||
<tr><th> | |||
<td>The starting column number of the range of columns in which the search string must be located. This is an optional argument, and it defaults to 1.</td></tr> | <tr><th><var>StartColumn</var></th> | ||
<tr><th> | <td>The starting column number of the range of columns in which the search string must be located. This is an optional argument, and it defaults to 1.<br/>Under <var class="product">Sirius Mods</var> 8.1 and later, this is a [[Notation conventions for methods#Named parameters|name allowed]] parameter.</td></tr> | ||
<td>The ending column number of the range of columns in which the search string must be located. This is an optional argument which defaults to 6124. If | |||
<tr><th> | <tr><th><var>EndColumn</var></th> | ||
<td>An indicator for case-insensitive comparisons. If this argument is a non-zero integer, the string comparisons use the Stringlist item data translated to uppercase (so the search string should be passed as an uppercase value). This is an optional argument, and | <td>The ending column number of the range of columns in which the search string must be located. This is an optional argument which defaults to 6124. If <var class="term">endCol</var> is a non-zero integer, the width of the column range is reduced to a maximum of 256. | ||
<br/>Under <var class="product">Sirius Mods</var> 8.1 and later, this is a name allowed parameter.</td></tr> | |||
<tr><th><var>CaseIndependent</var></th> | |||
<td>An indicator for case-insensitive comparisons. If this argument is a non-zero integer, the string comparisons use the <var>Stringlist</var> item data translated to uppercase (so the search string should be passed as an uppercase value). This is an optional argument, and defaults to 0. If this argument is non-zero, the width of the column range specified by the second and third argument values is reduced to a maximum of 256. | |||
<br/>Under <var class="product">Sirius Mods</var> 8.1 and later, this is a name allowed parameter.</td></tr> | |||
<tr><th><var>ArbitraryQuote</var></th> | |||
<td>An indicator for abitrary quote comparisons. If this argument is a non-zero integer, single (') and double(") quotes are considered matches for each other in the string comparisons. This is an optional argument, and defaults to 0. If this argument is non-zero, the width of the column range specified by the second and third argument values is reduced to a maximum of 256. This argument can be useful when searching through procedures that contain code where single and double quotes can be used interchangeably to enclose string literals. Such code includes User Language, Javascript, and XML (including XSLT). | |||
<p> | |||
This parameter, available in <var class="product">Sirius Mods</var> 8.1 and later, is a name allowed parameter.</p></td></tr> | |||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul><li>If the input Stringlist was associated with an image, by either | <ul> | ||
<li>If the input <var>Stringlist</var> was associated with an image, by either <var>[[BindImage (Stringlist function)|BindImage]]</var> or <var>[[New (Stringlist constructor)|New]]</var>, the <var>Subset</var> output <var>Stringlist</var> identifier is associated with the same image. | |||
<li>While, under <var class="product">Sirius Mods</var> Version 6.6 and later, <var>Stringlist</var> items can be longer than 6124 bytes long, <var>Subset</var> will only look for matches in the first 6124 bytes of any <var>Stringlist</var> item. | |||
</ul> | |||
==Examples== | ==Examples== | ||
In the following example, a Stringlist is loaded from the contents of a procedure, and all lines that contain the string | In the following example, a <var>Stringlist</var> is loaded from the contents of a procedure, and all lines that contain the string <code>'%critical'</code> (independent of case) are displayed: | ||
< | <p class="code">%list = new | ||
%list = new | |||
%rc = $procopn('BIGPROC', 'PROCFILE') | %rc = $procopn('BIGPROC', 'PROCFILE') | ||
%list:appendOpenProcedure | %list:appendOpenProcedure | ||
%list = %list:subset('%CRITICAL', , , 1) | %list = %list:subset('%CRITICAL', , , 1) | ||
% | %list:print | ||
</ | </p> | ||
==See also== | |||
{{Template:Stringlist:Subset footer}} |
Latest revision as of 00:50, 1 November 2012
Create Stringlist subset (Stringlist class)
This method creates a Stringlist that is a subset of the method Stringlist. The subset is created by selecting all entries that contain a specified search string.
Syntax
%outList = sl:Subset( string, [[StartColumn=] number], [[EndColumn=] number], - [[CaseIndependent=] number], [[ArbitraryQuote=] number])
Syntax terms
%outlist | A reference to a Stringlist which is set to the newly-created subset Stringlist. |
---|---|
sl | A Stringlist object. |
string | The string to be located. This argument is called the search string. |
StartColumn | The starting column number of the range of columns in which the search string must be located. This is an optional argument, and it defaults to 1. Under Sirius Mods 8.1 and later, this is a name allowed parameter. |
EndColumn | The ending column number of the range of columns in which the search string must be located. This is an optional argument which defaults to 6124. If endCol is a non-zero integer, the width of the column range is reduced to a maximum of 256.
Under Sirius Mods 8.1 and later, this is a name allowed parameter. |
CaseIndependent | An indicator for case-insensitive comparisons. If this argument is a non-zero integer, the string comparisons use the Stringlist item data translated to uppercase (so the search string should be passed as an uppercase value). This is an optional argument, and defaults to 0. If this argument is non-zero, the width of the column range specified by the second and third argument values is reduced to a maximum of 256.
Under Sirius Mods 8.1 and later, this is a name allowed parameter. |
ArbitraryQuote | An indicator for abitrary quote comparisons. If this argument is a non-zero integer, single (') and double(") quotes are considered matches for each other in the string comparisons. This is an optional argument, and defaults to 0. If this argument is non-zero, the width of the column range specified by the second and third argument values is reduced to a maximum of 256. This argument can be useful when searching through procedures that contain code where single and double quotes can be used interchangeably to enclose string literals. Such code includes User Language, Javascript, and XML (including XSLT).
This parameter, available in Sirius Mods 8.1 and later, is a name allowed parameter. |
Usage notes
- If the input Stringlist was associated with an image, by either BindImage or New, the Subset output Stringlist identifier is associated with the same image.
- While, under Sirius Mods Version 6.6 and later, Stringlist items can be longer than 6124 bytes long, Subset will only look for matches in the first 6124 bytes of any Stringlist item.
Examples
In the following example, a Stringlist is loaded from the contents of a procedure, and all lines that contain the string '%critical'
(independent of case) are displayed:
%list = new %rc = $procopn('BIGPROC', 'PROCFILE') %list:appendOpenProcedure %list = %list:subset('%CRITICAL', , , 1) %list:print