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



Alan, Kurt,

I would also prefer 2 procedures. But in Ken's example, the code that is set is a variable that is local to the procedure. Surely that is an advantage compared to using a global variable. If I use Set then Get, where would Get find the variable? Could I wrap InzTransactionCode with SetTransactionCode and GetTransactionCode?

P InzTransactionCode...
P B
D PI LIKE ( TRANSCD )
D ATrnCd LIKE ( TRANSCD ) CONST
D OPTIONS ( *NOPASS )

D wTrnCd S LIKE ( TRANSCD ) STATIC

/FREE

IF %PARMS > 0;
wTrnCd = ATrnCd;

ENDIF;

RETURN wTrnCd;

/END-FREE

P InzTransactionCode...

-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Alan Campin
Envoyé : mardi 13 octobre 2009 19:18
À : RPG programming on the IBM i / System i
Objet : Re: Procedure to set global variable

Yes, create two procedures. My rule is always can you describe what a
function(procedure) does without the use of a conjunctive
verb (And, Or). If you can't, then something is wrong.

On Tue, Oct 13, 2009 at 7:52 AM, Kurt Anderson
<kurt.anderson@xxxxxxxxxxxxxx
wrote:

You could have separate Set... and Get... procedures that
are wrappers
for this special procedure of yours to make it easy on the
calling program.
Although I'm not particularly fond of fusing what I
believe to be two
completely procedures into one (i.e. a SetGet... procedure).

-Kurt

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of David FOXWELL
Sent: Tuesday, October 13, 2009 2:19 AM
To: RPG programming on the IBM i / System i
Subject: RE: Procedure to set global variable


-----Message d'origine-----
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Ken Sims

But another way is to make the SetTransactionCode
procedure a SetGet
procedure. Make the transaction code parameter *NOPASS. Add a
return value for the transaction code.

When passed a transaction code, that value is saved and
also returned.

When not passed a transaction code, the saved value is returned.

Then the transaction code can be saved in a STATIC
variable local to
the SetGet procedure.



I've tried this out and I rather like it.

But how would you name this procedure?

If I do SetTransactionCode then GetTransActionCode, the
program code
is self-documenting. SetGetTransActionCode needs
commenting. I called
it InzTransActionCode.
--
This is the RPG programming on the IBM i / System i
(RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting,
please take a
moment to review the archives at
http://archive.midrange.com/rpg400-l.

--
This is the RPG programming on the IBM i / System i
(RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting,
please take a
moment to review the archives at
http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i / System i
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change
list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


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.