Difference between revisions of "Dbfield()"

From Recital Documentation Wiki
Jump to: navigation, search
 
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; /* The field 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 27: Line 27:
 
===DESCRIPTION===
 
===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]; /* Record buffer */
+
char record[1000]; /* Record buffer */
char name[10]; /* Name buffer */
+
char name[10]; /* Name buffer */
char fldvalue[10]; /* Field value */
+
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". RC);
+
printf("error no %d \n". rc);
 
exit(1);
 
exit(1);
 
}
 
}
else printf("Value of field %s is %sn", name, fldvalue);
+
else printf("Value of field %s is %s\n", name, fldvalue);
  
  

Revision as of 16:01, 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);


SEE ALSO

dbatofld(), dbgather(), dbgetf(), dbputr(), dbscatter()