Dbnkey()

From Recital Documentation Wiki
Revision as of 10:17, 2 April 2009 by Yvonnemilne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PURPOSE

read next key


SYNOPSIS

#include "dbl.h"
 
	int	dbnkey(ndx, key, recno)
 
	<input parameter>
	char	*ndx;		/* .NDX file descriptor			*/
 
	<output parameters>
	char	*key;		/* Address of a buffer where key is stored by the function	*/
	long	*recno;		/* Address of a variable where the record number is stored by the function	*/


RETURN VALUE

The dbnkey() function returns 0 for success, or < 0 if an error occurs. See the section on return code values for a detailed list of return codes.


DESCRIPTION

This function sequentially reads the next in ascending (or alphabetical) order and its corresponding record number from the specified .NDX file. If the function is called immediately after the file is open, it starts reading from the top of the file.


EXAMPLE

This example reads ten keys and their corresponding record numbers from the .NDX file whose file descriptor is specified in "char *ndx" and stores the keys and record numbers in "char nextkey[10][8]" and "long recno[10]" respectively. Keys are assumed to be numeric or date.

#include "dbl.h"
 
	char	*ndx;			/* .NDX file descriptor	*/
	char	nextkey[10][8];	/* Keys buffer			*/
	long	recno[10];		/* Record numbers buffer	*/
	int	it;			/* Loop control variable	*/
	int	rc;			/* Return code			*/
 
	for (i = 0; i < 10; ++i)
		if (dbnkey(ndx, &nextkey(i),&recno(i)) != SUCCESS)
			return(ERROR);


SEE ALSO

dbckey(), dbfwd(), dbgetnr(), dbpkey(), dbrewind()