Does anybody know how to convert a string to number in Cobol? we have 3 var as following:
03 NUM0 PIC X(6).
03 NUM1 PIC 9(06).
03 NUM2 PIC 9(06) VALUE 9754.
........................
MOVE '9754' TO NUM0
MOVE NUM0 TO NUM1
IF NUM1 = NUM2
DISPLAY "SUCCESSFUL!"
ELSE
DISPLAY "CONVERSION FAIL!"
END-IF
DISPLAY 'NUM0=' NUM0
DISPLAY 'NUM1=' NUM1
DISPLAY 'NUM2= ' NUM2
03 NUM1 PIC 9(06).
03 NUM2 PIC 9(06) VALUE 9754.
........................
MOVE '9754' TO NUM0
MOVE NUM0 TO NUM1
IF NUM1 = NUM2
DISPLAY "SUCCESSFUL!"
ELSE
DISPLAY "CONVERSION FAIL!"
END-IF
DISPLAY 'NUM0=' NUM0
DISPLAY 'NUM1=' NUM1
DISPLAY 'NUM2= ' NUM2
I got the output as following:
CONVERSION FAIL!
NUM0=9754
NUM1=9754 0
NUM2= 009754
******************************* Bottom of Data *
NUM0=9754
NUM1=9754 0
NUM2= 009754
******************************* Bottom of Data *
why is num1 "9754 0", how to convert "9754" to number 9754, thank you very much!
helen