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



ah yes...local variables rock 8^)

Thanks,
Tommy Holden



From:
Adam Glauser <adamglauser@xxxxxxxxx>
To:
rpg400-l@xxxxxxxxxxxx
Date:
01/29/2009 08:36 AM
Subject:
Re: CONST and VALUE revisited
Sent by:
rpg400-l-bounces@xxxxxxxxxxxx



-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Barbara Morris
Envoyé : jeudi 29 janvier 2009 02:43

There's one way a CONST parameter can be changed while the procedure
is running. If you pass a global variable by CONST to a subprocedure
in the same module, and the subprocedure modifies the global variable
directly, then the value of the CONST parameter may reflect the
change.

David FOXWELL wrote:
YES! That was it! That's the problem I have had come across from time to
time.

I admit it, in this case VALUE instead of CONST is a quick fix.
Normally, the program would be written in RPGLE and we'd use CONST and
that'd be it.

I'm not sure I follow you David. You're concerned with the value of the
parameter _after_ the procedure call is complete, right? Using VALUE
instead of CONST isn't going to make a difference in the case Barbara
mentions. The value of the variable will still be changed after the
procedure has finished. If a procedure references a global variable
directly, the only thing you can do is change the code in the procedure
to fix it.

This is exactly why procedures are preferred over subroutines in new
development. Changing (or even referencing) global variables in code
that is intended to be reused is almost always bad practice.

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.