Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
01 REQUIRED-VARIABLES.
05 NUMBER-TO-PARSE PIC X(20).
05 SIGN-CHAR PIC X.
88 NUMBER-IS-NEGATIVE VALUE "-".
05 INTEGER-CHARS PIC X(18) JUST RIGHT.
05 INTEGER-PORTION REDEFINES INTEGER-CHARS
PIC 9(18).
05 DECIMAL-CHARS PIC X(18).
05 DECIMAL-PORTION REDEFINES DECIMAL-CHARS
PIC V9(18).
05 START-POSITION PIC 99.
05 RESULTING-NUMBER PIC S9(18)V9(18).
MOVE ZEROS TO INTEGER-PORTION DECIMAL-PORTION.
MOVE 1 TO START-POSITION.
MOVE SPACES TO SIGN-CHAR.
INSPECT NUMBER-TO-PARSE TALLYING START-POSITION FOR LEADING SPACES.
IF NUMBER-TO-PARSE (START-POSITION: 1) "-" OR "+"
MOVE NUMBER-TO-PARSE (START-POSITION: 1) TO SIGN-CHAR
ADD 1 TO START-POSITION
END-IF.
UNSTRING NUMBER-TO-PARSE (START-POSITION:) DELIMITED BY "."
INTO INTEGER-CHARS DECIMAL-CHARS.
ADD INTEGER-PORTION DECIMAL-PORTION GIVING RESULTING-NUMBER.
IF NUMBER-IS-NEGATIVE
MULTIPLY -1 BY RESULTING-NUMBER
END-IF.
MOVE numeric-edited-item TO numeric-item.
I don't have a compiler available, so perhaps you would walk me thru the following:
I/P field: " +-1 57A2..999 "
Edit PIC : ? PIC ????
O/P field: " ???? "
01 a-strange-value value " +-1 57A2..999 ".
02 an-edited-number pic Z(18).
01 a-number-we-can-use pic S9(9)V9(9).
MOVE an-edited-number TO a-number-we-can-use.
MOVE 0 TO algebraic-sign-count, radix-count.
INSPECT a-strange-value
TALLYING algebraic-sign-count FOR ALL "+"
TALLYING algebraic-sign-count FOR ALL "-"
TALLYING radix-count FOR ALL ".".
IF algebraic-sign-count > 1 OR radix-count > 1
<process an error>
END-IF.