PLI Dynamic array creation



IBM's cross-platform compiler PL/I for MVS, VM & VSE, OS/390 and Enterprise PL/I for z/OS

Re: PLI Dynamic array creation

Postby NicC » Wed Jul 27, 2011 3:55 pm

Looks like you have two distinct pieces of work - parse the xml file then process the output of that parsing. So, split the processing into 2 programs - the first doing your parse and saving a count of the elements to a file, the second reads the count, allocates the array with the count as the number of elements, read the parsed input into the array and process.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: PLI Dynamic array creation

Postby NicC » Wed Jul 27, 2011 8:11 pm

Another option: read the elements onto the stack - counting them as you do so. When all are read allocate the array using the count then move the items off the stack and into the array.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: PLI Dynamic array creation

Postby prino » Wed Jul 27, 2011 9:31 pm

Build a linked list, and at the end, when you have the count, allocate an array of pointers and let each pointer in that array point to the appropriate element of the linked list.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 635
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times

Previous

Return to PL/I

 


  • Related topics
    Replies
    Views
    Last post