Difference between revisions of "Dbfield()"
From Recital Documentation Wiki
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(2 intermediate revisions by one user not shown) | |||
Line 11: | Line 11: | ||
<input parameter> | <input parameter> | ||
− | char *dbf; /* .DBF file descriptor | + | char *dbf; /* .DBF file descriptor */ |
− | char *record; /* Address of the buffer where the record is stored */ | + | char *record; /* Address of the buffer where the record is stored */ |
− | char *name; | + | char *name; /* The field name */ |
<output parameters> | <output parameters> | ||
− | char *buffer; /* Address of the buffer where the field value is stored as ASCII */ | + | char *buffer; /* Address of the buffer where the field value is stored as ASCII */ |
</code> | </code> | ||
Line 25: | Line 25: | ||
− | + | ==DESCRIPTION== | |
− | The dbfield() function extracts the values of the specified field "name" from the given "record" buffer and places the ASCII value in the specified "buffer". The dbgetf() function can be used to obtain the field names for a database. | + | The dbfield() function extracts the values of the specified field "name" from the given "record" buffer and places the ASCII value in the specified "buffer". The [[dbgetf()]] function can be used to obtain the field names for a database. |
Line 37: | Line 37: | ||
#include "dbl.h" | #include "dbl.h" | ||
− | char *dbf; /* .DBF file descriptor */ | + | char *dbf; /* .DBF file descriptor */ |
− | char record[1000]; | + | char record[1000]; /* Record buffer */ |
− | char name[10]; /* Name buffer | + | char name[10]; /* Name buffer */ |
− | char fldvalue[10]; | + | char fldvalue[10]; /* Field value */ |
− | int rc; /* Return code | + | int rc; /* Return code */ |
rc = dbfield ( dbf, record, name, fldvalue); | rc = dbfield ( dbf, record, name, fldvalue); | ||
if (rc != SUCCESS){ | if (rc != SUCCESS){ | ||
− | printf("error no %d n". | + | printf("error no %d \n". rc); |
exit(1); | exit(1); | ||
} | } | ||
− | else printf("Value of field %s is % | + | else printf("Value of field %s is %s\n", name, fldvalue); |
Latest revision as of 16:05, 3 April 2009
PURPOSE
extract the value of a specified field
SYNOPSIS
#include<dbl.h> int dbfield(dbf, record, name, buffer) <input parameter> char *dbf; /* .DBF file descriptor */ char *record; /* Address of the buffer where the record is stored */ char *name; /* The field name */ <output parameters> char *buffer; /* Address of the buffer where the field value is stored as ASCII */
RETURN VALUE
The dbfield() 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
The dbfield() function extracts the values of the specified field "name" from the given "record" buffer and places the ASCII value in the specified "buffer". The dbgetf() function can be used to obtain the field names for a database.
EXAMPLE
The following example extracts the value from the field "char *name" from the record buffer "char *record" whose file descriptor is in "char *dbf" and stores it in "char *fldvalue" as an ASCII string.
#include "dbl.h" char *dbf; /* .DBF file descriptor */ char record[1000]; /* Record buffer */ char name[10]; /* Name buffer */ char fldvalue[10]; /* Field value */ int rc; /* Return code */ rc = dbfield ( dbf, record, name, fldvalue); if (rc != SUCCESS){ printf("error no %d \n". rc); exit(1); } else printf("Value of field %s is %s\n", name, fldvalue);