gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] UNSTRING to Array


From: Bruce M. Axtens
Subject: [open-cobol-list] UNSTRING to Array
Date: Mon, 03 Jun 2013 20:52:08 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Thunderbird/22.0

I did find a better way, but it still involves knowing beforehand how many items are going to be pulled out of the string.

identification division.
program-id. unsinto.
environment division.
data division.
working-storage section.
01    datatable.
    03    datatab pic 9(9) occurs 5 times indexed by dat.
01    cnt    pic 99.
01    ptr pic 99.
01    datastring    pic x(10) value "9,8,7,6,5".
01    flow-control    pic 9 value 0.
        88 nothing-left value 1.
01    items    usage computational-1.
procedure division.
    move 1 to ptr.
    divide length of datatable by length of datatab giving items
    perform until nothing-left
        unstring datastring delimited by "," into datatab(dat) with pointer ptr tallying in cnt
        set dat up by 1
        if cnt = items
            exit perform
        end-if
        display dat " " datatab(dat) " " ptr " " cnt " length of datatab=" items
    end-perform.
    display datatable.
    goback.
    .
   

Does COBOL do dynamic arrays?

Kind regards,
Bruce.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]