Counts file items whose index keys meet specified conditions.
TCL-I command.
ICOUNT file-specifier WITH index-name {{operator} literalValue}
ICOUNT file-specifier WITH index-name [GT || GE] literalValue AND [LT || LE] literalValue
file-specifier Specifies a file as defined in Conventions, except that file modifiers cannot be used because indexes are only definable on data sections.
index-name The name of an index associated with the file.
operator One of the following relational operators: EQ, GT, GE, LT or LE. If the operator and literal value are omitted, a count of all indexed item-ids is displayed. If a literal value is specified, but no operator, the EQ operator is used.
literalValue A literal string enclosed in single or double quotes. If the operator is EQ, a trailing ] character is interpreted as a wildcard (see Wildcard Searching).
ICOUNT is similar to the English COUNT command in that it counts items meeting specified conditions. The difference is that ICOUNT uses a file index to count items whose keys meet a specified condition.
ICOUNT cannot work from an active select list. If a select list is active
when ICOUNT is invoked, the message Abandoning previous select list [ICOUNT]
is displayed and the list is
discarded before returning the count information.
On completion, ICOUNT generates the following message:
itemCount item(s) from keyCount unique index key(s) counted.
where itemCount is the number of items meeting the selection criteria and keyCount is the number of unique keys.
The following example counts all items in the file CUST.FILE that are indexed on XREGION:
ICOUNT CUST.FILE WITH XREGION
To count a subset of the indexed items, specify selection criteria; that is, an operator and a literal string value to match. Valid operators are EQ, LT, GT, GE, and LE.
The following example counts all items in a file indexed on XREGION whose keys are greater than A1.
ICOUNT CUST.FILE WITH XREGION GT "A1"
More complex matching can be performed by combining selection criteria with the AND connective. Under these circumstances, you must use GE or GT to specify the lower limit and LE or LT the upper limit of the required range of keys (see Syntax); the EQ operator is not valid. For example, to count the portion of CUST.FILE with key values greater than or equal to A1 and less than B1, use the following command:
ICOUNT CUST.FILE WITH XREGION GE "A1" AND LT "B1"
Note: Using the AND connective with ICOUNT counts keys that fall between specified values; that is, keys that are greater than, or greater than or equal to the lower key value, and less than, or less than or equal to the higher key value. The keys meeting this condition represent a contiguous group of keys within the index. Any other form for multiple selection criteria is invalid and produces an error message.
When using the EQ operator, the literal value can end with the ] wildcard character. The following example counts all the key values that begin with A.
ICOUNT CUST.FILE WITH XREGION EQ "A]"