× 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.



 > If you have to define it at the maximum occurs, what does being dynamic
buy you?  Would you immediately go in at program startup and resize it back
down
to a reasonable number?  Would that be the benefit?

Although you define it as the max size, because it is "based" no storage is
allocated by the compiler.  SO you allocate how much you want - say 100
elements worth.  Later you discover you need 200 elements so you increase
the size.  If you didn't base it - the additional storage would be "wasted".
You can continue to grow until you reach the RPG limit.

 > You say "as for an array".  I thought I had seen examples of people
starting off with a 100 element array and then resizing it to 200?  You
can't do that?

Not unless you have sized it for 200+ - No.  Again you start by allocating
for 100 elements and then increase the allocation when you need it.  There's
an example of all this that I wrote in the "Sorcerers Guide" including the C
qsort and bsearch routines.

Hopefully one day IBM will give a more "genuine" dynamic storage model for
MODS and arrays - but until then this is it.

 > So, would the I/O module have to declare the MODS at the maximum Occurs,
get the records, then reallocate the MODS back down to the actual number of
records retrieved, then return to the calling program?  Then, the calling
program would have to do the same thing, start off with a maximum size ds,
and reallocate it down after it got the pointer back from the I/O module?

No.  You don't quite have the hang of dynamic memory I suspect.  First of
all the IO routine would just increase its allocation as required as I
explained above.  Second, when the caller received the pointer it would
simply use it to base its own version of the MODS.  It would never own any
storage or have to resize anything.  It would just reference the storage
owned by the IO routine.

Jon Paris
Partner400




As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.