COUNTKEYS


9.4

 

The COUNTKEYS instruction counts the keys in an ISAM file from a starting value to an ending value. The instruction uses the following formats:

 

 

[label]

COUNTKEYS

{ifile}{sep}{startkey}{sep1}{endkey}{sep2}{keycount}

 

Where:

label

Optional. A Program Execution Label.

ifile

Required. A previously defined and opened IFILE variable.

sep1

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.

startkey

Required. A previously defined Character String Variable that contains the key to start counting from inclusively.

sep2

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, INTO or GIVING.

endkey

Required. A previously defined Character String Variable that contains the key to stop counting from inclusively.

keycount

Required. A previously defined Numeric Variable where the number of counted keys is stored.

Flags Affected: OVER, ZERO

Note the following:

  1. If the {keycount} is equal to zero, the ZERO Condition Flag is set.

  2. If {keycount} is too small to contain the count, the OVER Condition Flag is set.

  3. The {startkey} and {endkey} should contain the 'key data' that would be expected when performing a normal IFILE READ operation.

  4. The COUNTKEYS instruction applies normal file locking techniques the same as in a normal IFILE READ. This insures the integrity of the file while ISAM keys are being counted.

 

 

See Also: Example Code, Disk I/O Instructions

 



PL/B Language Reference CLOSE DELETE