COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Example 220 TEST-NUMVAL Function
Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. TEST-NUMVAL.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DATA.
03 A PIC S9(4).
PROCEDURE DIVISION.
MAIN-LOGIC SECTION.
MOVE FUNCTION TEST-NUMVAL("35") to A.
DISPLAY A.
MOVE FUNCTION TEST-NUMVAL("35.") to A.
DISPLAY A.
MOVE FUNCTION TEST-NUMVAL("35.75") to A.
DISPLAY A.
MOVE FUNCTION TEST-NUMVAL(".35") to A.
DISPLAY A.
MOVE FUNCTION TEST-NUMVAL("=35.75") to A.
DISPLAY A.
MOVE FUNCTION TEST-NUMVAL("35.75 CR") to A.
DISPLAY A.
STOP RUN.
Output:
0000
0000
0000
0000
0001
0000
TEST-NUMVAL-C Function
TEST-NUMVAL-C, an integer function, returns a value indicating whether the specified character-string
is valid input to the NUMVAL-C Function (page 680).
string
is a nonnumeric literal or an alphanumeric data item.
currency-sign
the optional currency-sign is a nonnumeric literal or alphanumeric data item; a string of
one or two characters that specifies the currency sign. The default is the currency sign specified
for the program. For more information, refer to the NUMVAL-C Function (page 680).
The returned value is zero if string conforms to the format described for the argument of the
NUMVAL-C Function (page 680), or gives the character position of the first invalid character. If
string is valid but incomplete (for example, it contains no digits), the returned value is the length
of the string plus one (indicating the character position immediately following string).
694 Intrinsic Functions