Prepare a DBMONEY value for calls to dbmnyndigit.
RETCODE dbmnyinit(dbproc, mnyptr, trim, negative) DBPROCESS *dbproc; DBMONEY *mnyptr; int trim; DBBOOL *negative;
A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library uses to manage communications and data between the front end and the server.
This parameter may be NULL. The DBPROCESS is used as a parameter to an application’s error handler. It also contains information on what language to print error messages in. If a DBPROCESS is not supplied, the default national language is used.
A pointer to the DBMONEY value to be initialized. dbmnyinit changes the value of *mnyptr.
The number of digits to trim from *mnyptr. dbmnyinit removes digits from *mnyptr by dividing it by a power of 10. The value of trim determines what power of 10 is used. trim cannot be less than 0.
A pointer to a DBBOOL variable. If *mnyptr is negative, dbmnyinit makes it positive and sets *negative to “true”.
SUCCEED or FAIL.
dbmnyinit returns FAIL if mnyptr is NULL, negative is NULL, or trim is less than 0.
dbmnyinit initializes a DBMONEY value for conversion to character. It eliminates unwanted precision and converts negative values to positive.
dbmnyinit eliminates digits from a DBMONEY value by dividing by a power of 10. The integer trim determines what power of 10 is used. dbmnyinit modifies *mnyptr, replacing the original value with the trimmed value. If *mnyptr is negative, dbmnyinit makes it positive and sets *negative to “true”.
dbmnyinit and dbmnyndigit are useful for writing a custom DBMONEY-to-DBCHAR conversion routine. Such a custom routine might be useful if the accuracy provided by dbconvert’s DBMONEY-to-DBCHAR conversion (hundredths of a dollar) is not adequate. Also, dbconvert does not build a character string containing commas.
dbmnyndigit returns the rightmost digit of a DBMONEY value as a DBCHAR. To get all the digits of a DBMONEY value, call dbmnyndigit repeatedly. See the dbmnyndigit reference page for more details.
dbmnyinit is almost always used in conjunction with dbmnyndigit. Used alone, dbmnyinit can force negative DBMONEY values positive and divide DBMONEY values by a power of 10, but the real purpose of dbmnyinit is to prepare a DBMONEY value for calls to dbmnyndigit.
The range of legal DBMONEY values is between +/-$922,337,203,685,477.5808. DBMONEY values have a precision of one ten-thousandth of a dollar.
The dbmnyndigit reference page contains an example that demonstrates the use of dbmnyinit.