True and False (SelectionCriterion functions)

From m204wiki
Revision as of 02:13, 23 June 2011 by JAL2 (talk | contribs) (Created page with "{{Template:SelectionCriterion:True and False subtitle}} These shared methods take no parameters and create a new SelectionCriterion object. A TRUE criterion returns true for any...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Create selection expression that returns any item or no items (SelectionCriterion class)


These shared methods take no parameters and create a new SelectionCriterion object. A TRUE criterion returns true for any collection item; a FALSE criterion returns false for any collection item.

TRUE and FALSE thus provide the equivalent of an empty SelectionCriterion, and they substitute for a New constructor in the SelectionCiterion class.

The collection searching method (?? refid=srchcol.) that makes use of a selection criterion specifies:

  • Whether to return the first item or item number or all items that satisfy the selection criterion.
  • Where in the collection to begin searching.

Syntax

%selectionCriterion = [%(SelectionCriterion For itemType):]True

%selectionCriterion = [%(SelectionCriterion For itemType):]False

Syntax terms

%selc
A SelectionCriterion object variable to contain the new object instance.
%(selectionCriterion for itemtype)
This optional specification of the class and collection item type in parentheses indicates that the method is shared and does not operate on a specific instance.

Usage Notes

  • TRUE and FALSE exist to simplify dynamic SelectionCriterion applications. If you are dynamically generating a SelectionCriterion, under some conditions you may want the criterion to select all objects or to select no objects. In addition, if you are building a SelectionCriterion by using OR in conditions, it might be useful to start out with a FALSE SelectionCriterion:
        %sel = FALSE
        if <somecondition1> then %sel = OR(%sel, EQ(foo, 'A'))
        end if
        if <somecondition2> then %sel = OR(%sel, EQ(foo, 'B'))
        end if
        if <somecondition3> then %sel = OR(%sel, EQ(foo, 'C'))
        end if
    

    Similarly, if building a SelectionCriterion by using AND in conditions, it might be useful to start out with a TRUE SelectionCriterion.

Examples

The following statements are equivalent:

    %sel = and(ge(this, 22), true)

    %sel = ge(this, 22)