HP 3000 Manuals

NUMVAL-C Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

NUMVAL-C Function 

The NUMVAL-C function returns the numeric value represented by the
character string specified by parameter-1.  Any optional currency sign
specified by parameter-2 and any optional commas preceding the decimal
point are ignored.  The function type is numeric.

Syntax 

     FUNCTION NUMVAL-C (parameter-1 {parameter-2})

Parameters 

parameter-1           Must be a nonumeric literal or alphanumeric data
                      item whose content has one of the following
                      formats:

[]
where space is a string of zero or more spaces, cs is the string of one or more characters specified by parameter-2, and digit is a string of one or more digits. If the DECIMAL-POINT IS COMMA clause is specified in the SPECIAL-NAMES paragraph, the functions of the comma and decimal point in parameter-1 are reversed. The total number of digits in parameter-1 must not exceed 18. parameter-2 If specified, must be a nonnumeric literal or alphanumeric data item. If parameter-2 is not specified, the character used for cs is the currency symbol specified for the program. Return Value The returned value is the numeric value represented by parameter-1. Example 1 77 ALPHA-NUM PIC X(16) VALUE "$ 123.45 CR ". 77 NUM PIC S9(5)V99. PROCEDURE DIVISION. 010-PARA. COMPUTE NUM = FUNCTION NUMVAL-C (ALPHA-NUM). DISPLAY ALPHA-NUM. DISPLAY NUM. STOP RUN. The above example displays the following: $ 123.45 CR -00123.45 Example 2 ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. DATA DIVISION. WORKING-STORAGE SECTION. 77 ALPHA-NUM PIC X(16) VALUE SPACES. 77 NUM PIC S9(5)V99. PROCEDURE DIVISION. 010-PARA. MOVE "DM 1.150,25" TO ALPHA-NUM. COMPUTE NUM = FUNCTION NUMVAL-C (ALPHA-NUM "DM"). DISPLAY ALPHA-NUM. DISPLAY NUM. STOP RUN. The above example displays the following: DM 1.150,25 +01150,25


MPE/iX 5.0 Documentation