gnucobol-users
[Top][All Lists]
Advanced

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

Re: [open-cobol-list] UNSTRING to Array


From: Michael Anderson
Subject: Re: [open-cobol-list] UNSTRING to Array
Date: Mon, 03 Jun 2013 15:20:57 -0500
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

YES!
The ON EXCEPTION clause of UNSTRING combined with increasing the occurs of datatab, may help this to be more variable.
You'll still have a maximum limit, as with all things good.


On 06/03/2013 07:52 AM, Bruce M. Axtens wrote:
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.



------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2


_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list


reply via email to

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