the number of (objects)

This construct returns the number of objects in the current data set or in the specified collection.

Purpose

You use this construct to count the number of objects of the specified type and return the total as a number.

Syntax

the number of <objects> [in <list>], [where <test>,*]

Description

You can use the optional in <list> clause to count the objects in a specific list. You can use one or more optional where clauses to apply more conditions to the objects that are included in the returned count.

You cannot use this construct directly in the then part of a rule. To use the result of this construct in the then part of a rule, you must first define it as a variable in the definitions part.

Examples

The following condition is met if there are at least 6 vehicles:

if
   the number of vehicles is more than 5
then...

In the following rule, the number of transactions that are under 100 is defined as a variable in the definitions part, so that it can be reused in the then part:

when a transaction occurs, called 'the transaction'
definitions
   set 'all' to the number of transactions ;
   set 'small' to the number of transactions,
      where the amount is less than 100 ;
if
   small is more than 10
then
   print "There are" + small + "transactions under 100" ;