Dbgetf()
From Recital Documentation Wiki
Revision as of 12:58, 1 May 2009 by Yvonnemilne (Talk | contribs)
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()