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


  • Subject: Re: Automatic Storage for Global RPGLE Variables?
  • From: bmorris@xxxxxxxxxx
  • Date: Fri, 15 Jun 2001 20:25:16 -0400
  • Importance: Normal


>Date: Fri, 15 Jun 2001 12:05:22 -0700
>From: "Jerry Jewel" <jerryjewel@email.com>
> ...
>Some additional info and to complicate things a bit... my global control
values already reside in four >data structures -- three of them are
multiple occurance.
>
>o  Will I will need to execute an ALLOC (in 3b of your description) to set
asside the storage?
> ...

Jerry, one way to handle this would be to create one more
data structure with pointers to all the other control data
structures.  First you would allocate the pointer-DS, then
you would allocate all its pointers.

D master_ctl       ds       based(pMaster_ctl)
D  pCtl_ds_1             *
D  pCtl_ds_2             *

D ctl_ds_1         ds       based(pCtl_ds_1)
D  ...
D ctl_ds_2         ds       based(pCtl_ds_2)
D                           occurs(10)

c      eval    pMaster_ctl = %alloc(%size(master_ctl))
c      eval    pCtl_ds_1 = %alloc(%size(ctl_ds_1))
c      eval    pCtl_ds_2 = %alloc(%size(ctl_ds_2:*all))
...

(using V5R1's %alloc to avoid having to declare named constants
for the %size's that would be necessary for ALLOC)

If it were possible for you to have callers with interleaved calls
to your functions, using a stack approach wouldn't work.  You could
use a similar approach to the one Scott suggested, but rather than
have your service program figure out which pointer to use, have your
callers pass it around to you.  Your MakeXXXX function would return
the pointer to the caller, and then the caller would pass it back
to you when it wanted to do the functions.  (You'd have to add a
"cleanupXXXX" function if you don't already have one.)

eval  myXXXX = makeXXXX()
eval  whatever = someXXXXfn (myXXXX : some parms)
callp destroyXXXX (myXXXX)

One more alternative - rather than give the user a pointer that
they could use incorrectly, you could give them an array index.  Your
code would store their pointer in an array.

One tricky bit, since you have recursive calls going on here: you
either have to code all the based control structures in each function
(using /copy, or LIKEDS if you have V5R1), or your functions have to
save off the current master pointer when they start, and restore it
when they return.

Barbara Morris

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

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.