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




On Fri, 26 Apr 2002, Joel R. Cochran wrote:
>
> Ooooh!  I guessed right!  How do you define it as static?

You just have to put the "static" keyword on the d-spec.  Keep in mind
that this means that the "plan" array will be changed each time you
call your subprocedure (as opposed to a new copy being created).

It also means that the procedure wouldn't be threadsafe -- but that
probably doesn't matter to you since RPG itself isn't threadsafe :)

> How would you  pass a memory allocation, or do you mean pass the sales
> array as a variable with VALUE option?

Well, passing it by value would create the same problem -- the data
would be local to the subprocedure and would be destroyed when it
ended.

Instead of making the sales array a "based" array, I'd make it a
normal array, pass the address of the array, then make "plan" a
based array.

So, it'd be something like:

     Dsales            S             11P 3 dim(12)

(etc, etc)

     c                   callp     getPlanedSales(%addr(sales): itnbr:
     c                                 fiscalYr: seq#)

(etc, etc)

     PgetPlanedSales   B
     DgetPlanedSales   PI
     D  p_sales                        *   value
     D  itnbr                        15A   const
     D  year                          4P 0 const
     D  seq                           3P 0 const

     Dp_plan           S               *
     Dplan             S             11P 3 based(p_plan)

     c                   eval      p_plan = p_sales

(etc, etc)

That way it would be threadsafe.   Also, if you ever had multiple arrays,
such as maybe "sales", "overhead", "admin", you could call the same
subproc with them, and not worry about it reusing the same static storage
for each.

Just a thought...




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.