Difference between revisions of "Dbxgoto()"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
Line 12: Line 12:
  
 
<input parameters>
 
<input parameters>
char *dbx; /* Tagged index file descriptor */
+
char *dbx; /* Tagged index file descriptor */
long recno; /* Record number to go to */
+
long recno; /* Record number to go to */
  
  
Line 40: Line 40:
 
<code lang="c">
 
<code lang="c">
 
#include <stdio.h>
 
#include <stdio.h>
#include "dbl.h" /* Recital/Library include file */
+
#include "dbl.h" /* Recital/Library include file */
#include "dblproto.h" /* Recital/Library prototype file */
+
#include "dblproto.h" /* Recital/Library prototype file */
  
 
static dBFIELD fields[6] = {
 
static dBFIELD fields[6] = {
Line 59: Line 59:
 
main()
 
main()
 
{
 
{
int rc; /* Return Code for error handling */
+
int rc; /* Return Code for error handling */
char *dbf; /* File descriptor for table */
+
char *dbf; /* File descriptor for table */
char *dbx; /* File descriptor for tagged index */
+
char *dbx; /* File descriptor for tagged index */
long db_size; /* Size of table variable */
+
long db_size; /* Size of table variable */
  
rc = dbdcache(100);
+
rc = dbdcache(100);
errorproc("dbdcache()","table cache specified.", rc);
+
errorproc("dbdcache()","table cache specified.", rc);
rc = dbicache(100);
+
rc = dbicache(100);
errorproc("dbicache()", "index cache specified.", rc);
+
errorproc("dbicache()", "index cache specified.", rc);
rc = dbfilemode(1,0);
+
rc = dbfilemode(1,0);
rc = dbopen("shipwreck.dbf", &dbf);
+
rc = dbopen("shipwreck.dbf", &dbf);
errorproc("dbopen()","table opened in shared mode.", rc);
+
errorproc("dbopen()","table opened in shared mode.", rc);
  
rc = dbsize(dbf, &db_size);
+
rc = dbsize(dbf, &db_size);
errorproc("dbsize()", "size retrieved.", rc);
+
errorproc("dbsize()", "size retrieved.", rc);
printf("t   No. of Records: t%dn", db_size);
+
printf("\t   No. of Records: \t%d\n", db_size);
 
 
rc = dbxgoto(dbx, db_size);
+
rc = dbxgoto(dbx, db_size);
errorproc("dbxgoto()", "gone to last physical record in table.", rc);
+
errorproc("dbxgoto()", "gone to last physical record in table.", rc);
  
rc = dbxclose(dbx);
+
rc = dbxclose(dbx);
errorproc("dbxclose()", "tagged index closed.", rc);
+
errorproc("dbxclose()", "tagged index closed.", rc);
rc = dbclose(dbf);
+
rc = dbclose(dbf);
errorproc("dbclose()", "table closed.", rc);
+
errorproc("dbclose()", "table closed.", rc);
  
exit(0);
+
exit(0);
 
}
 
}
  
Line 93: Line 93:
 
{
 
{
 
if ( rc != SUCCESS ) {
 
if ( rc != SUCCESS ) {
printf("n  Error performing function %s -> %dn", func, rc);
+
printf("\n  Error performing function %s -> %d\n", func, rc);
exit(1);
+
exit(1);
 
}
 
}
printf("Function: t%s, t%s - Okn", func, str);
+
printf("Function: \t%s, \t%s - Ok\n", func, str);
 
return;
 
return;
 
}
 
}

Latest revision as of 15:40, 5 May 2009

PURPOSE

go to specified record number and reposition keys in index tag


SYNOPSIS

#include "dbl.h"
 
	int	dbxgoto(dbx, recno)
 
	<input parameters>
	char	*dbx;		/* Tagged index file descriptor */
	long	recno;		/* Record number to go to */
 
 
	<output parameters>
	none


RETURN VALUE

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


DESCRIPTION

The dbxgoto() function will go to the specified record number in the table associated with the tagged file. The record number specified becomes the current record and the index tag is repositioned.


EXAMPLE

The following example checks how many records are in the table, then goes to the last physical record in the table.


#include <stdio.h>
#include "dbl.h"			/* Recital/Library include file */
#include "dblproto.h"		/* Recital/Library prototype file */
 
	static	dBFIELD fields[6] = {
		"VESSEL",	'C',	18,	0,	0,
		"LAT",	'N',	4,	1,	0,
		"LONG",	'N',	4,	1,	0,
		"AMOUNT",	'N',	10,	0,	0,
		"DATE",	'D',	8,	0,	0,
		"FLAG",	'C',	9,	0,	0
	};
 
	static void errorproc(
		char	*func,
		char	*str,
		int	rc);
 
	main()
	{
		int	rc; 			/* Return Code for error handling */
		char	*dbf; 		/* File descriptor for table */
		char	*dbx; 		/* File descriptor for tagged index */
		long	db_size;		/* Size of table variable */
 
		rc = dbdcache(100);
		errorproc("dbdcache()","table cache specified.", rc);
		rc = dbicache(100);
		errorproc("dbicache()", "index cache specified.", rc);
		rc = dbfilemode(1,0);
		rc = dbopen("shipwreck.dbf", &dbf);
		errorproc("dbopen()","table opened in shared mode.", rc);
 
		rc = dbsize(dbf, &db_size);
		errorproc("dbsize()", "size retrieved.", rc);
		printf("\t	  No. of Records: \t%d\n", db_size);
 
		rc = dbxgoto(dbx, db_size);
		errorproc("dbxgoto()", "gone to last physical record in table.", rc);
 
		rc = dbxclose(dbx);
		errorproc("dbxclose()", "tagged index closed.", rc);
		rc = dbclose(dbf);
		errorproc("dbclose()", "table closed.", rc);
 
		exit(0);
}
 
	static void errorproc(func, str, rc)
	char	*func;
	char	*str;
	int	rc;
{
	if ( rc != SUCCESS ) {
		printf("\n  Error performing function %s -> %d\n", func, rc);
		exit(1);
	}
	printf("Function: \t%s, \t%s - Ok\n", func, str);
	return;
}


SEE ALSO

dbxfwd(), dbxrewind()