I'm trying to unstring my input-line which is seperated with ";", into an array. But i'm having trouble with displaying every word after the first ";".
So basically, Input: Hello;Stack;Overflow
Output: Value: 2 (because of 2 semicolons)
Line 1 of my Record Table: Hello
Line 2 of my Record Table: Stack
Line 3 of my Record Table: Overflow
My code so far:
*-------------------------------------------------------------
LINKAGE SECTION.
01 X-INPUT-LINE PIC X(2000).
01 X-SEP-CHAR PIC X(1).
01 X-RET-TABLE.
02 CMAX PIC 9(5) COMP-3.
02 ENTRY-REC OCCURS 0 TO 9999 TIMES DEPENDING ON CMAX
INDEXED BY CIDX.
04 ENTRY-REC2.
07 LINEVALUE PIC X(100).
PROCEDURE DIVISION USING X-INPUT-LINE
X-SEP-CHAR
X-RET-TABLE.
MAIN SECTION.
MN-00.
INITIALIZE WERT.
INSPECT X-INPUT-LINE TALLYING WERT FOR ALL
X-SEP-CHAR.
MOVE X-INPUT-LINE TO VAL.
ADD 1 TO WERT.
PERFORM WERT TIMES
MOVE WERT TO LINEVALUE OF X-RET-TABLE (WERT)
UNSTRING VAL DELIMITED BY ";"
INTO STRVAL
END-UNSTRING
IF CMAX OF X-RET-TABLE < 9999
ADD 1 TO CMAX OF X-RET-TABLE
MOVE STRVAL TO ENTRY-REC(CMAX OF X-RET-TABLE)
END-IF
END-PERFORM.
With my following code I can only display the "Hello" in my example and the program displays it 3 times in 3 different rows.