SubsetImageItem (Stringlist function): Difference between revisions
m (syntax diagram, tags and links) |
m (→Examples) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 30: | Line 30: | ||
desc is string len 30 | desc is string len 30 | ||
end image | end image | ||
... | |||
fr products | fr products | ||
%product:code = code | %product:code = code | ||
Line 37: | Line 37: | ||
%list:addImage('PRODUCT') | %list:addImage('PRODUCT') | ||
end for | end for | ||
... | |||
%product:type = 'WIDGET' | %product:type = 'WIDGET' | ||
%wlist = %list:subsetImageItem(%product:type) | %wlist = %list:subsetImageItem(%product:type) | ||
Line 55: | Line 55: | ||
<p class="code">%olist= %list:subsetImageItem(%product:code, -2, , 'GE') | <p class="code">%olist= %list:subsetImageItem(%product:code, -2, , 'GE') | ||
</p> | </p> | ||
</ol> | |||
==See also== | ==See also== | ||
{{Template:Stringlist:SubsetImageItem footer}} | {{Template:Stringlist:SubsetImageItem footer}} |
Latest revision as of 00:51, 1 November 2012
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. |
imageItem | 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 imageItem 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 sl 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 searchValue is specified in addition to the imageItem, processing is performed as if the searchValue were first assigned to the imageItem, and then the imageItem is restored to its original value upon processing completion. Any data type conversions required between the searchValue and the imageItem 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')