_RetCurrency( ) API Library Routine Example

The following example converts a numeric type value to currency type value.

Visual FoxPro Code

SET LIBRARY TO RETCURR
? xntom(100.1)

C Code

#include <pro_ext.h>
#include <math.h>

void FAR retcurr(ParamBlk FAR *parm)
{
   CCY money;

   money.HighPart = (long) (parm->p[0].val.ev_real*10000 / pow(2,32));
   
   money.LowPart = (unsigned long) ((parm->p[0].val.ev_real - (double) (money.HighPart * pow(2,32)/10000.0)) *10000);
   
   _RetCurrency(money,25);
}

FoxInfo myFoxInfo[] = {
   {"XNTOM", (FPFI) retcurr, 1, "N"}
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};