This function extracts a set of items, according to a user define criteria, from an item string to form a new item string.
Syntax
ListFilter(cValueExpr,cFilterExpr,cReturnExpr,cSeparator,cSubItemSeparator)
Argument |
Description |
cValueExpr |
Item string (or MCL function returning an item string) |
cFilterExpr |
A logic expression for filtering items. You may use ListCol( ) and ListColVal( ) to compose the expression. ListCol( ) is referred to an item string or sub-item string while ListColVal( ) is referred to the numeric value of an item string or sub-item string. See examples below for details. |
cReturnExpr |
An expression for forming the return items. You may use ListCol( ) and ListColVal( ) to compose the expression. ListCol( ) is referred to an item string or sub-item string while ListColVal( ) is referred to the numeric value of an item string or sub-item string. See examples below for details. If the argument is omitted, the whole item will be included in the return string. |
cSeperator |
Item separator (can be more than 1 character). Default to ',' |
cSubItemSeparator |
Sub-item separator (can be more than 1 character). Default to '-' |
Returns
Character
Example
ListFilter("8,4,3,12",'ListCol( )>"3"')
Returns '8,4'. Among the items in the item string, only '8' and '4' are greater than 3. Please note that in string comparison, '12' is smaller than '3'.
ListFilter("8,4,3,12",'ListColVal( )>3')
Returns '8,4,12'。If items are converted to numbers, only the third item, 3, is not greater then 3.
ListFilter("A-5,J-4,C-13,K-12",'ListCol(1)>"D"')
Returns 'J-4,K-12'. ListCol(1) is used for specifying the value criterion for the first sub-item, among the all the first sub-items 'A','J','C', and 'K', only 'J' and 'K' are greater than 'D'. Therefore 'J-4,K-12' is returned.
ListFilter("A-5,J-4,C-13,K-12",'ListColVal(2)>10')
Returns 'C-13,K-12'. ListColVal(2) is used for specifying the criterion for selecting the 2nd sub-item. The items will be converted to number for before selection is made. Among the four sub-items (5,4,13,12), 13 and 12 are greater than 10, therefore 'C-13,K-12' is returned.
ListFilter("A-5,J-4,C-13,K-12",'ListColVal(2)>10','ListCol(1)')
Returns 'C,K'. Similar to the example above, ListColVal(2) is used for specifying the criterion for the 2nd sub-item. The third argument ListCol(1) specifies that only the first sub-item is to be included in the returning string. Therefore 'C,K' is returned.
ListFilter("A 5 5/J 4 6/C 7 8",'ListColVal(2)+ListColVal(3)>9'
And ListCol(1)<"D"','ListColVal(2)+ListColVal(3)',"/"," ")
Returns '10,15'. This example shows that you may use compound expression for both the filter expression and return value expression. Among the items, 'A 5 5' and 'C 7 8' meet the criteria ListColVal(2)+ListColVal(3)>9 (5+5>9,7+8>9) and ListCol(1)<"D" ("A"<"D","C"<"D"). The returning item string is formed by ListColVal(2)+ListColVal(3), i.e., 5+5 and 7+8, hence '10,15'.
Page url: http://www.racematenet.com/english/help/index.html?listfilter.htm