× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Why not simply define the input parameter as a data structure like this:

     D BndSrvPgm_t     ds                  qualified based(template)
     D   SpCount                      5I 0
     D   BndSrvPgm_                  10A   dim(32767)

     D MyPgm           pr                  extpgm('MYPGM')
     D   BndSrvPgm                         likeds(BndSrvPgm_t) const
     D MyPgm           pi
     D   BndSrvPgm                         likeds(BndSrvPgm_t) const

If you do that, you won't have to use %subst() in a loop to move it to an array, and you won't have to worry about dynamically allocating memory. (The command will, however, dynamically allocate only as many elements as needed, so make sure you don't try to use any past the number in SpCount)

---
Scott Klement  http://www.scottklement.com


On Wed, 8 Mar 2006, Holden Tommy wrote:

Looking for advice...

The following code works fine for my purposes at the moment.  Since I
have a little extra time on this project I'd like to have this as a
service program.  Basically I use this for command interfaces.  When
receiving parameter data from the command interface, the data comes in
as varsize with a 5i 0 parameter length.  Instead of having to duplicate
this code for each keyword that can return multiple values, I would like
to have a procedure that I pass the number of entries for the parameter,
received data string & dynamically allocate the space for the data &
return a pointer to the data.

Here's the working example:

For i = 0 To ( SpCount - 1 );
 BndSrvPgm_(i+1) = %Subst(BindSrvPgm
                         :3 + ( i * %Size(SrvPgm_) )
                         :%Size(SrvPgm_));
EndFor;

I'd like to do something like this in my main procedure:

ParmPtr = DynamicArray(EntryCount : EntryData);

& have a dynamic array DS based on the return pointer.  Since I can't
use a variable DIM count to define the dynamic array DS, what would you
folks suggest??

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.