CNV_CURRENCYEDITTMP_DOUBLE

This procedure receives a double-precision integer and formats it to represent a currency value according to the template specified in the TEMP_ARY parameter. The template can be retrieved for any convention from the CNV_TEMPLATE procedure. The template can also be created by the user. CE_ARY contains the formatted currency value. The MultiLingual System Administration, Operations, and Programming Guide describes the symbols used to create a template.

Example

This example converts a double-precision integer and edits in numeric symbols, which are passed in as a monetary template. The currency symbol is retrieved from the monetary template in the ASERIESNATIVE convention and edited into the EBCDIC string.

   BEGIN

      $ INCLUDE INTL="SYMBOL/INTL/ALGOL/PROPERTIES." 10000000 - 49999999

        FILE OUT(KIND=DISK,UNITS=CHARACTERS,MYUSE=IO,FILETYPE=0,
        NEWFILE, MAXRECSIZE=80,TITLE="OUT/ALGOL/CUREDITTMPDOUB.");
        DEFINE MAX_NAME_LEN = 17#; % Maximum length of convention name
        EBCDIC ARRAY CNV_NAME[0:MAX_NAME_LEN - 1],
        CE_ARY[0:29], TMP_ARY[0:47];
        INTEGER CE_LEN, RESULT, PRECISION;
        DOUBLE AMT;

        AMT := 1234567 @@ 0;
        PRECISION := 2;
        REPLACE CNV_NAME BY "ASERIESNATIVE";
        REPLACE TMP_ARY BY "!N[-]CT[,:0,3]D[.]#!";
        RESULT := CNV_CURRENCYEDITTMP_DOUBLE
                  (AMT, PRECISION, TMP_ARY, CNV_NAME, CE_LEN, CE_ARY);
        WRITE(OUT,<"RESULT = ",J4>,RESULT);
           IF RESULT EQL CS_DATAOKV THEN
             WRITE(OUT,<"CE_ARY = ",C30>,CE_ARY);
           CLOSE(OUT,LOCK);
         END.

Output

RESULT = 1
CE_ARY = $12,345.67

In this call, the parameters have the following meanings:

AMT is a double-precision integer passed to the procedure. This integer contains the value of the currency.

TMP_ARY is an EBCDIC array passed to the procedure. This array contains the formatting template used to format the currency value.

CNV_NAME is an EBCDIC array passed to the procedure. This array contains the name of the convention to be used. When a caller-supplied monetary template (in TMP_ARY) contains one or more control characters in simple form (control character without a symbol definition enclosed in square brackets ([]) following it), symbols associated with those control characters are retrieved from the monetary template in the convention specified by CNV_NAME.

For example, if a caller-provided monetary template is !N[-]CT[,:0,3]D[.]#! and CNV_NAME contains Sweden, then the local currency symbol is retrieved from the monetary template in Sweden convention and the amount 12345.67 is edited into a formatted string as Kr.12,134.67.

CE_LEN is an integer returned by the procedure. This integer contains the length of the formatted value in the output array.

CE_ARY is an EBCDIC array returned by the procedure. This array contains the formatted monetary value.

PRECISION is an integer passed to the procedure. This integer specifies the number of digits in AMT to be placed after the decimal symbol.

RESULT is an integer returned by the procedure. This integer indicates whether an error occurred during the execution of the procedure. An explanation of the error result values and messages can be found at the end of this section. The values returned by this procedure include:

CS_BAD_ARRAY_DESCRIPTIONV (3000)

CS_DATAOKV (1)

CS_BAD_AMTV (3009)

CS_FAULTV (1001)

CS_BAD_DATA_LENV (3002)

CS_SOFTERRV (1002)

CS_BAD_PRECISIONV (3038)