SubsetImageItem (Stringlist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 1: Line 1:
{{Template:Stringlist:SubsetImageItem subtitle}}
{{Template:Stringlist:SubsetImageItem subtitle}}


This method locates all Stringlist items that exactly match the contents of an image item, or that match a value converted to the image item format at the offset and length of the image item, and it places these image items into a new Stringlist that is a subset of the old Stringlist. The SubsetImageItem method accepts three arguments and returns a Stringlist.
This method locates all <var>Stringlist</var> items that exactly match the contents of an image item, or that match a value converted to the image item format at the offset and length of the image item, and it places these image items into a new <var>Stringlist</var> that is a subset of the old <var>Stringlist</var>. The SubsetImageItem method accepts three arguments and returns a <var>Stringlist</var>.


==Syntax==
==Syntax==
Line 8: Line 8:
<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>item</th>
<tr><th>item</th>
<td>The image item to be matched.</td></tr>
<td>The image item to be matched.</td></tr>
Line 16: Line 16:
<td>The value to be found. This is an optional argument. When this argument is not specified, the current contents of the image item specified by the '''item''' argument is used as the match value.</td></tr>
<td>The value to be found. This is an optional argument. When this argument is not specified, the current contents of the image item specified by the '''item''' argument is used as the match value.</td></tr>
<tr><th>operator</th>
<tr><th>operator</th>
<td>A string comparison operator that indicates the required relationship between the match value and the item in the '''%sl''' Stringlist. Valid comparison operators are <tt>.EQ</tt>, <tt>.NE</tt>, <tt>.LE</tt>,<tt>.LT</tt>, <tt>.GE</tt>, and <tt>.GT</tt>. If this argument is not specified or null, an equality test (<tt>.EQ</tt>) is done on all $list items.</td></tr>
<td>A string comparison operator that indicates the required relationship between the match value and the item in the '''%sl''' <var>Stringlist</var>. Valid comparison operators are <tt>.EQ</tt>, <tt>.NE</tt>, <tt>.LE</tt>,<tt>.LT</tt>, <tt>.GE</tt>, and <tt>.GT</tt>. If this argument is not specified or null, an equality test (<tt>.EQ</tt>) is done on all $list items.</td></tr>
</table>
</table>


Line 22: Line 22:
<ul><li>All errors in SubsetImageItem result in request cancellation.</ul>
<ul><li>All errors in SubsetImageItem result in request cancellation.</ul>
==Examples==
==Examples==
SubsetImageItem is especially useful for Stringlists whose contents map to an image, as for example in the following:
SubsetImageItem is especially useful for <var>Stringlist</var>s whose contents map to an image, as for example in the following:


<pre>
<pre>
Line 59: Line 59:


For inequality comparisons, the appropriate image-item datatype-specific comparison is performed.
For inequality comparisons, the appropriate image-item datatype-specific comparison is performed.
For example, the following method selects all Stringlist items with a product code of -2, -1, or any number greater than or equal to zero, but it does not select any with a product code of -3 or less.
For example, the following method selects all <var>Stringlist</var> items with a product code of -2, -1, or any number greater than or equal to zero, but it does not select any with a product code of -3 or less.


<pre>
<pre>

Revision as of 21:33, 18 January 2011

Create Stringlist subset based on image item (Stringlist class)


This method locates all Stringlist items that exactly match the contents of an image item, or that match a value converted to the image item format at the offset and length of the image item, and it places these image items into a new Stringlist that is a subset of the old Stringlist. The SubsetImageItem method accepts three arguments and returns a Stringlist.

Syntax

%outList = sl:SubsetImageItem( imageItem, [searchValue], [operator])

Syntax terms

%outlist A reference to a Stringlist which is set to the newly-created subset Stringlist.
sl A Stringlist object.
item The image item to be matched.
searchvalue The value to be found. This is an optional argument. When this argument is not specified, the current contents of the image item specified by the item argument is used as the match value.
operator A string comparison operator that indicates the required relationship between the match value and the item in the %sl Stringlist. Valid comparison operators are .EQ, .NE, .LE,.LT, .GE, and .GT. If this argument is not specified or null, an equality test (.EQ) is done on all $list items.

Usage notes

  • All errors in SubsetImageItem result in request cancellation.

Examples

SubsetImageItem is especially useful for Stringlists whose contents map to an image, as for example in the following:

image product
code is binary len 2
type is string len 8
desc is string len 30
end image
...
fr products
%product:code = code
%product:type = type
%product:desc = desc
%list:addImage('PRODUCT')
end for
...
%product:type = 'WIDGET'
%wlist = %list:subsetImageItem(%product:type)

If a value is specified in addition to the image item, processing is performed as if the value were assigned to the image item, and then the image item is restored to its original value. Any data type conversions required between the value and the image item are performed before the subsetting is performed. That is, this method invocation:

%olist = %list:subsetImageItem(%product:code, 13)

is identical to this:

%temp = %product:code
%product:code = 13
%olist = %list:subsetImageItem(%product:code)
%product:code = %temp

For inequality comparisons, the appropriate image-item datatype-specific comparison is performed. For example, the following method selects all Stringlist items with a product code of -2, -1, or any number greater than or equal to zero, but it does not select any with a product code of -3 or less.

%olist= %list:subsetImageItem(%product:code, -2, , 'GE')