CNV_CONVERTCURRENCY_STAR

This procedure converts a string containing digits and monetary symbols to a real number.

Example

This example converts an EBCDIC string containing digits and monetary symbols to a real number. The ASERIESNATIVE ccsversion is used.

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/CNVCONVERTCURSTAR.");
  DEFINE MAX_NAME_LEN        = 17#;    % Maximum length of convention
                                       % name
  EBCDIC ARRAY CNV_NAME[0:MAX_NAME_LEN - 1], CC_ARY[0:9];
  INTEGER VSN_NUM, CC_ARY_SIZE, CNV_NAME_SIZE, RESULT;
  REAL AMT;

  VSN_NUM := 0;
  REPLACE CC_ARY BY "$12,345.67";
  REPLACE CNV_NAME BY "ASERIESNATIVE";
  CC_ARY_SIZE := SIZE(CC_ARY);
  CNV_NAME_SIZE := SIZE(CNV_NAME);
  RESULT := CNV_CONVERTCURRENCY_STAR(VSN_NUM, CC_ARY, CC_ARY_SIZE,
                                     CNV_NAME, CNV_NAME_SIZE, AMT);
  WRITE(OUT,<"RESULT = ",J4>,RESULT);
  IF RESULT EQL CS_DATAOKV THEN
    WRITE(OUT,<"AMT    = ",F8.2>,AMT);
  CLOSE(OUT,LOCK);
END.

Output

RESULT = 1
AMT    = 12345.67

In this call, the parameters have the following meanings:

VSN_NUM is an integer passed to the procedure. It contains the number of the ccsversion that was in effect when the input string was created. If the input string contains alternate digits, then they will be translated to their corresponding 0-9 numbers. Refer to the MultiLingual System Administration, Operations, and Programming Guide for a list of the ccsversion numbers. The values allowed for VSN_NUM and the meanings of the values are as follows:

Value

Meaning

Greater than or equal to 0

Use the specified ccsversion number.

–2

Use the system default ccsversion. If the system default ccsversion is not available, an error is returned.

CC_ARY is an EBCDIC array that contains the input string of digits and monetary symbols.

CC_ARY_SIZE is an integer that contains the total number of bytes in CC_ARY.

CNV_NAME is an EBCDIC array that is passed to the procedure. It contains the name of the convention to be used to format the input string. If this parameter contains all blanks or zeros, the procedure uses the hierarchy to determine the convention to be used. Refer to the MultiLingual System Administration, Operations, and Programming Guide for the list of convention names and an explanation of the hierarchy.

CNV_NAME_SIZE is an integer that contains the total number of bytes in CNV_NAME.

AMT is a real number that is returned by the procedure. It contains the converted real number.

RESULT is an integer returned by the procedure. It indicates whether or not 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_ARRAY_TOO_SMALLV (3001)

CS_FILE_ACCESS_ERRORV (1000)

CS_BAD_ARRAY_DESCRIPTIONV (3000)

CS_DATA_NOT_FOUNDV (4002)

CS_BAD_DATA_LENV (3002)

CS_DATAOKV (1)

CS_BAD_INPUTVALV (3035)

CS_FAULTV (1001)

CS_CONVENTION_NOT_FOUNDV (2002)

CS_SOFTERRV (1002)