Difference between revisions of "Dbgetf()"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(3 intermediate revisions by one user not shown)
Line 11: Line 11:
  
 
<input parameter>
 
<input parameter>
char *dbf; /* Address of the .DBF file descriptor*/
+
char *dbf; /* Address of the .DBF file descriptor */
  
 
<output parameters>
 
<output parameters>
int reclen; /* Record length in bytes */
+
int reclen; /* Record length in bytes */
char *month; /* File creation/update month */
+
char *month; /* File creation/update month */
char *day; /* File creation/update day */
+
char *day; /* File creation/update day */
char *year; /* File creation/update year */
+
char *year; /* File creation/update year */
int *nofields; /* Number of fields in a record */
+
int *nofields; /* Number of fields in a record */
dbfield *fields; /* Array of record fields */
+
dbfield *fields; /* Array of record fields */
  
 
</code>
 
</code>
Line 31: Line 31:
 
==DESCRIPTION==
 
==DESCRIPTION==
  
This function obtains database information such as month, day and year of its creation or last update, record length, number of fields per record and contents of each field.  The buffer "fields" must be big enough to hold the maximum number of dBFIELD structures – 128 (maximum number of fields per record).
+
This function obtains database information such as month, day and year of its creation or last update, record length, number of fields per record and contents of each field.  The buffer "fields" must be big enough to hold the maximum number of dBFIELD structures – 256 (maximum number of fields per record).
  
  
Line 41: Line 41:
 
#include<dbl.h>
 
#include<dbl.h>
  
char *dbf; /* .DBF file descriptor */
+
char *dbf; /* .DBF file descriptor */
int reclen; /* Record length */
+
int reclen; /* Record length */
char month, day, year; /* Date of last update */
+
char month, day, year; /* Date of last update */
int nofields; /* Number of fields per record */
+
int nofields; /* Number of fields per record */
dBFIELD fields[128]; /* Fields buffer */
+
dBFIELD fields[256]; /* Fields buffer */
int rc; /* Return code */
+
int rc; /* Return code */
int i; /* For loop counter */
+
int i; /* For loop counter */
  
 
rc = dbgetf(dbf,
 
rc = dbgetf(dbf,
Line 53: Line 53:
 
&day, &year,
 
&day, &year,
 
&nofields, fields);
 
&nofields, fields);
if (rc = = SUCCESS) {
+
if (rc == SUCCESS) {
printf("reclen=%d month=%d day=%d year=%d,,
+
printf("reclen=%d month=%d day=%d year=%d,nofields=%d \n", reclen, month, day, year, nofields);
nofields=%d n", reclen, month, day, year, nofields);
+
 
for (i = 0; i < nofields,++i)
 
for (i = 0; i < nofields,++i)
printf("%d Field Name: %s", i +1, fields[i].fieldnm);
+
printf("%d Field Name: %s", i +1,fields[i].fieldnm);
 
}else{
 
}else{
printf("error number %dn", rc);
+
printf("error number %d\n", rc);
 
exit [1];
 
exit [1];
 
}
 
}

Latest revision as of 12:58, 1 May 2009

PURPOSE

get .dbf file information


SYNOPSIS

#include "dbl.h"
 
	int	dbgetf(dbf, reclen, month, day, year, nofields, fields)
 
	<input parameter>
	char		*dbf;			/* Address of the .DBF file descriptor */
 
	<output parameters>
	int		reclen;		/* Record length in bytes */
	char		*month;		/* File creation/update month */
	char		*day;		/* File creation/update day */
	char		*year;		/* File creation/update year */
	int		*nofields;		/* Number of fields in a record */
	dbfield	*fields;		/* Array of record fields */


RETURN VALUE

The dbgetf() functions 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 obtains database information such as month, day and year of its creation or last update, record length, number of fields per record and contents of each field. The buffer "fields" must be big enough to hold the maximum number of dBFIELD structures – 256 (maximum number of fields per record).


EXAMPLE

This example reads database information from the .dbf file and prints record length, update information and number of fields per record on standard output.

#include<dbl.h>
 
	char		*dbf;				/* .DBF file descriptor */
	int		reclen;			/* Record length */
	char		month, day, year;	/* Date of last update */
	int		nofields;			/* Number of fields per record */
	dBFIELD	fields[256];		/* Fields buffer */
	int		rc;				/* Return code */
	int		i;				/* For loop counter */
 
	rc = dbgetf(dbf,
			&reclen, &month,
			&day, &year,
			&nofields, fields);
	if (rc == SUCCESS) {
		printf("reclen=%d month=%d day=%d year=%d,nofields=%d \n", reclen, month, day, year, nofields);
		for (i = 0; i < nofields,++i)
			printf("%d Field Name: %s", i +1,fields[i].fieldnm);
	}else{
		printf("error number %d\n", rc);
		exit [1];
	}


SEE ALSO

dbatofld(), dbcreat(), dbfield(), dbfldtoa(), dbgetfx(), dbgetr()