Previous Topic

Next Topic

NbrOfKeysInRange

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

Short Name

RNGENT()

Type

Low-level index file function

Declaration

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

Description

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 Plus function that retrieves data using indices. This function is very helpful for controlling list boxes requiring “thumb operations”.

Return

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 Plus Error Codes” in the c-tree Plus Programmer’s Reference Guide for a complete listing of valid c-tree Plus 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.

Example

#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:");
gets(idxval1);
TransformKey(2,idxval1);      /* properly form index value 1 */

memset(idxval2,' ',maxbuf);
printf("\n\tEnter last name for range:");
gets(idxval2);
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()