It's definitely possible.

Any variables that are to retain their values must NOT be in automatic storage, though. In RPG, that means coding the STATIC keyword on them, or coding them as global variables. (Or parameters, I guess.)

D IsLoaded s 1n static inz(*off)
D loadedValue s 10a static
/free
if not IsLoaded;
chain 123 SETTINGS;
if %found;
loadedValue = SETTING;
isLoaded = *on;
endif;
endif;
return loadedValue;

On 3/17/2011 3:38 PM, Thomas Garvey wrote:
Is it possible to code a procedure in a service program such that it can
retain values from one call to the next? I haven't been able to accomplish
this and I could cut down on some logic if it can be done.

An example would be: if a flag has not been set (procedure never called
before), retrieve some static values from a database. If the flag IS set,
those values are already set and available for use in the current call to
the procedure.

Thanks

Tom Garvey




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