[TOC] [Prev] [Next] [Bottom]



<@FILTER>

Syntax

<@FILTER ARRAY=arrayVarName EXPR=filterExpr [SCOPE=scope]>

Description

Given an array, this meta tag returns an array containing rows matching a specified expression. The ARRAY attribute specifies the name of a variable containing an array. The EXPR attribute specifies the expression to use when evaluating each row to determine whether it will be in the array returned. In this expression, the values from the current row are specified with a number sign (#), followed by the column name or number. (See the examples following.) This expression may use any operators and functions supported by the <@CALC> tag. If the expression evaluates to 1 (true) for a particular row, that row appears in the output array.

The SCOPE attribute specifies the scope of the variable specified in the value of the ARRAY attribute. If SCOPE is not specified, the default scoping rules are used.

Meta tags are permitted in any of the attributes, but see the following note. Meta tags specified in EXPR are evaluated for each row in ARRAY.


!Note: References to columns inside the EXPR attribute cannot be specified by meta tags.


Examples

  • Assume the local variable resultSet contains the following array:

    3243 Acme Insurance ACTIVE
    2344 Fairview Electronics INACTIVE
    2435 Vanguard Computing INACTIVE
    1234 Cinetopia ACTIVE
    5421 Trailblazer Industries ACTIVE

    <@FILTER ARRAY="resultSet" SCOPE="local" EXPR="#3=ACTIVE"> returns:

    3243 Acme Insurance ACTIVE
    1234 Cinetopia ACTIVE
    5421 Trailblazer Industries ACTIVE

  • Assume the user variable orders contains the following array and that column two is named amount and column three is named state:

    1000 324.78 NY
    1001 849.25 MA
    1002 1245.97 CT
    1003 400.45 CA
    1004 598.10 NY
    1005 53.89 ME
    1006 1800.76 NY

    <@FILTER ARRAY="orders" SCOPE="user" EXPR="(#amount > 500) and (#state = NY)"> returns:

    1004 598.10 NY
    1006 1800.76 NY

  • Assume the user variable accounts contains the following array and that column two is named credit and column three is named debit:

    987235-2347 3257.65 2049.12
    324234-9848

    5234.37

    6097.90
    234349-2823 0.00 56.33
    630780-8491 657.78 347.20
    324969-1983 234561.27 229679.18
    196573-8436 326.62 192.20
    537030-4739 9482.40 10274.23

    Also assume the value -100 is stored in the variable od_limit.

    <@FILTER ARRAY="accounts" SCOPE="user" EXPR="(#credit - #debit) < @@od_limit"> returns:

    324234-9848 5234.37 6097.90
    537030-4739 9482.40 10274.23

See Also

<@DISTINCT>
<@INTERSECT>
<@SORT>
<@UNION>



[TOC] [Prev] [Next] [Bottom]



docs@pervasive.com

Copyright © 1998, Pervasive Software Inc. All rights reserved.