title: COBOL Unstring into an Array
body: <p>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 ";".</p>
  
  <p>So basically, Input: Hello;Stack;Overflow</p>
  
  <hr>
  
  <p>Output: Value: 2  (because of 2 semicolons)</p>
  
  <hr>
  
  <p>Line 1 of my Record Table: Hello</p>
  
  <hr>
  
  <p>Line 2 of my Record Table: Stack</p>
  
  <hr>
  
  <p>Line 3 of my Record Table: Overflow</p>
  
  <p>My code so far:</p>
  
  <pre><code>*-------------------------------------------------------------
   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 &lt; 9999                   
     ADD  1  TO CMAX OF X-RET-TABLE               
     MOVE STRVAL TO ENTRY-REC(CMAX OF X-RET-TABLE)
  
  END-IF                                          
  END-PERFORM.    
  </code></pre>
  
  <p>With my following code I can only display the "Hello" in my example and the program displays it 3 times in 3 different rows.</p>