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 WS-INPUT PIC X(??).
01 WS-OUTPUT PIC 9(10).
.
.
.
MOVE ZEROS TO WS-OUTPUT
MOVE 1 TO IDX2
PERFORM VARYING IDX FROM 1 BY 1
UNTIL IDX > LENGTH OF (WS-INPUT) OR
IDX2 = 10
IF WS-INPUT(IDX:1) IS NUMERIC
MOVE WS-INPUT(IDX:1) TO WS-OUTPUT(IDX2:1)
ADD 1 TO IDX2
END-IF
END-PERFORM
IDENTIFICATION DIVISION.
PROGRAM-ID. FILTER01.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 PROCESSING-DATA.
04 INPUT-VALUE PIC X(20).
04 TEMP-VALUE1 PIC X(20).
04 TEMP-VALUE2 PIC X(20).
04 POINTER-VALUE PIC S9(4) BINARY.
04 OUT-VALUE PIC X(20).
04 OUT-NUMBER PIC 9(10).
04 OUT-NUM-TEXT REDEFINES OUT-NUMBER PIC X(10) JUST RIGHT.
04 OUT-BINARY PIC S9(10) BINARY.
04 EOS-FLAG PIC X.
04 DUMMY-CHAR PIC X.
PROCEDURE DIVISION.
0000-MAIN SECTION.
DISPLAY "TESTING FILTER. TYPE QUIT IN ALL CAPS TO END.".
PERFORM 1000-PROCESS UNTIL INPUT-VALUE = "QUIT".
GOBACK.
1000-PROCESS SECTION.
DISPLAY "ENTER PHONE NUMBER.".
MOVE SPACES TO INPUT-VALUE.
ACCEPT INPUT-VALUE.
INSPECT INPUT-VALUE CONVERTING "(-)"
TO " ".
MOVE 1 TO POINTER-VALUE.
MOVE SPACES TO OUT-VALUE.
MOVE "N" TO EOS-FLAG.
PERFORM UNTIL POINTER-VALUE > 20
UNSTRING INPUT-VALUE DELIMITED BY ALL SPACES
INTO TEMP-VALUE1
WITH POINTER POINTER-VALUE
END-UNSTRING
MOVE SPACES TO TEMP-VALUE2
STRING OUT-VALUE DELIMITED BY SPACES
TEMP-VALUE1 DELIMITED BY SPACES
INTO TEMP-VALUE2
END-STRING
MOVE TEMP-VALUE2 TO OUT-VALUE
END-PERFORM.
UNSTRING OUT-VALUE DELIMITED BY SPACES
INTO OUT-NUM-TEXT
END-UNSTRING.
MOVE OUT-NUMBER TO OUT-BINARY.
DISPLAY "PHONE NUMBER IS: " OUT-BINARY.