FIELD VALUE()

From Recital Documentation Wiki
Revision as of 16:40, 27 March 2009 by Yvonnemilne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PURPOSE

Return a field value


SYNONYM

api_field_value()


SYNOPSIS

#include "dbapi.h"
 
int	FIELD_VALUE(fldname, value)
 
<input parameters>
char	*fldname;		/* Address of a buffer containing a field name	*/
 
<output parameters>
char	*value;		/* Address of a buffer to return the field value	*/


DESCRIPTION

The FIELD_VALUE() function will update the specified buffer with the value in the specified field from the currently selected database.

All database field types are automatically converted by Recital to character strings. The values from Memo and Blob fields are not copied into the buffer, instead the word "MEMO" is returned.


EXAMPLE

The following example gets the value of all the fields from the example database and returns the specified field by the number of the parameter passed to the function. See appendix A for the data structure of "example.dbf".

#include "dbapi.h"
 
dbapi_field_value()
{
    int	rc;
    int	element_no;
    char	*fldbuf[12];
    char	blob[5];
    char	byte[3];
    char	character[21];
    char	date[9];
    char	dfloat[11];
    char	integer[5];
    char	logical[2];
    char	number[11];
    char	memo[5]
    char	real[11];
    char	word[11];
    char	zoned[11];
 
    if (_parinfo(1) != API_NTYPE) _retc("");
 
    fldbuf[0] = blob;
    fldbuf[1] = byte;
    fldbuf[2] = character;
    fldbuf[3] = date;
    fldbuf[4] = dfloat;
    fldbuf[5] = integer;
    fldbuf[6] = logical;
    fldbuf[7] = number;
    fldbuf[8] = memo;
    fldbuf[9] = real;
    fldbuf[10] = word;
    fldbuf[11] = zoned;
 
    element_no = _parni(1) -1;
 
    rc = COMMAND("use example");
    if (rc == 0 ) {
       if (element_no > FIELD_COUNT() || element_no < 0) {
       COMMAND("use");
       _retc("Field number out of bounds.");
       }
       rc=FIELD_VALUE ("blob",blob);
       rc=FIELD_VALUE ("byte",byte);
       rc=FIELD_VALUE ("char",character);
       rc=FIELD_VALUE ("date",date);
       rc=FIELD_VALUE("float",float);
       rc=FIELD_VALUE ("int",int);
       rc=FIELD_VALUE ("number",number);
       rc=FIELD_VALUE ("memo",memo);
       rc=FIELD_VALUE ("real",real);
       rc=FIELD_VALUE ("word",word);
       rc=FIELD_VALUE ("zoned",zoned);
       COMMAND("use");
 
    } else {
       _retc( "");
    }
 
    _retc(fldbuf[element_no]);
}


SEE ALSO

BLOB_READ(), DBF_FETCH(), DBF-READ(), DBF_RECBUFFER(), DBF_SCATTER() FIELD_COUNT(), FIELD_LOOKUP(), FIELD_NAME(), FIELD_UPDATE(), MEMO_MLINE(), MEMO_READ()