Dbfldtoa()

From Recital Documentation Wiki
Jump to: navigation, search

PURPOSE

convert numeric field to ASCII


SYNOPSIS

#include "dbl.h"
 
	int	dbfldtoa(field, width, ascii)
 
	<input parameters>
	char	*field;		/* Field to be converted */
	int	width;		/* Width of the field */
 
	<output parameters>
	char	*ascii;		/* Address of the buffer where the converted ASCII string is returned */


RETURN VALUE

The dbfldtoa() function returns 0 for success. See the section on return code values for a detailed list of return codes.


DESCRIPTION

This function converts a numeric field of a record containing a floating-point number to ASCII format. RECITAL/Library functions manipulate records/fields as ASCII data, therefore functions like this and others which allow data conversion must be utilized. The length of the resulting string equals the width of the field + 1, the string is null terminated.

NOTE: Make sure that the output character buffer is at least 1 byte longer than the "width" input parameter, since a NULL character is added to the output string. The value of "width" must be the same as the value specified when creating the .DBF file. If the value is forgotten, it can be obtained by calling the dbgetf() function.


EXAMPLE

This example converts a numeric field of 10 digits wide located at "record + 29" into an ASCII character string and stores the result in "char ascii[11]".

#include "dbl.h"
 
        char record[100];	/* Record buffer */
        char ascii[11];	/* ASCII form of numeric field */
        int rc;			/* Return code */
 
        rc = dbfldtoa(record + 29, 10, ascii);
        if (rc == SUCCESS) 
        {
            printf("copy successful \n");
        }
        else 
        {
            printf("error message %d \n", rc);
            exit (1);
        }

SEE ALSO

dbatofld(), dbcreat(), dbgetf(), dbkeytoa()