Compartir a través de


_RetFloat( ) API Library Routine

Sets the library return value to a float value.

void _RetFloat(double flt, int width, int dec)
double flt;                  /* Double precision floating point
 value. */
int width;                     /* Number of columns for number
 display. */
int dec;                     /* Number of decimal places. */

Remarks

The width parameter specifies the number of columns Visual FoxPro uses when displaying the number, including a decimal point if one is needed. If you don't know the width, use 20. The dec parameter specifies the number of decimal places in the number. You must correctly set the number of decimal places to guarantee that Visual FoxPro correctly processes the number. If the number of decimal places isn't zero, the width must be at least two greater than dec.

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example uses _RetFloat( ) to return the floating point representation of a Visual FoxPro date parameter.

Visual FoxPro Code

SET LIBRARY TO RETFLOAT
? RETFLOAT({2/16/95})  && returns float representation of date {2/16/95}

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
   _RetFloat(parm->p[0].val.ev_real, 20, 4);
}

FoxInfo myFoxInfo[] = {
   {"RETFLOAT", (FPFI) Example, 1, "D"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

_RetChar( ) API Library Routine | _RetCurrency( ) API Library Routine | _RetDateStr( ) API Library Routine | _RetDateTimeStr( ) API Library Routine | _RetInt( ) API Library Routine | _RetLogical( ) API Library Routine | _RetVal( ) API Library Routine