Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic


Return the number of active index entries found between two targets .

Short Name



Low-Level index file function


LONG NbrOfKeysInRange(FILNO keyno, pVOID idxval1, pVOID idxval2)


In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering

NbrOfKeysInRange() returns the number of active index entries found between idxval1 and idxval2 for index file keyno. idxval1 and idxval2 must be properly formed keys, as is necessary with any c-tree function that retrieves data using indexes. This function is very helpful for controlling list boxes requiring “thumb operations”.

Note: A huge file may return values greater than 4 GB. This function returns the low-order 4-byte word of the 8-byte number of keys. To get the high-order 4-byte word, call ctGETHGH(). A return of zero is not necessarily an error if there are exactly a multiple 4 GB worth of key values.


On success, NbrOfKeysInRange() returns the number of active index entries found between the given targets. If an error occurs or the index file is empty, NbrOfKeysInRange() returns zero. When NbrOfKeysInRange() returns zero, check uerr_cod: if uerr_cod is non-zero, an error condition was detected; otherwise, no key values are in the index. See c-tree Error Codes in the c-tree Programmer’s Reference Guide for a complete listing of valid c-tree error values.

The following example uses a duplicate allowed index over customer name. The code prompts the user for a beginning name and an ending name for the range. ActiveRange() takes the number of active index entries between the two values entered by the user.


#define maxbuf 40

TEXT idxval1[maxbuf]; /* input buffer one */

TEXT idxval2[maxbuf]; /* input buffer two */

LONG ActiveRange;

memset(idxval1,' ',maxbuf);

printf("\n\tEnter first name for range:");


TransformKey(2,idxval1); /* properly form index value 1 */

memset(idxval2,' ',maxbuf);

printf("\n\tEnter last name for range:");


TransformKey(2,idxval2); /* properly form index value 2 */

ActiveRange = NbrOfKeysInRange(2,idxval1,idxval2);

printf("\nRNGENT for Parent Key is %ld uerr_cod = %d", ActiveRange,uerr_cod);

See also

GetORDKey(), NbrOfKeyEntries()