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



Something along those lines, however if there is more complicated calculations involved you could think about creating sub-subprocedures:

RtnVar = *ON
IF NOT Control()
RtnVar = DoControlStuff()
ENDIF
IF NOT Extract()
RtnVar = DoExtractStuff()
ENDIF
...Etc...

RETURN RtnVar

And yes, if there is a XOR relation between the conditions you can/should replace this with your ELSEIF variaty.

But this would give you the tool to inject a single IF just above the RETURN statement, and as long as you can guarantee that the value of RtnVar is *OFF if it is set off independant of the other condition you can simply do so. If there is a difference between handling a RtnVar == *OFF from one condition to another you can also clearly reflect this by inserting that handling within the same IF or ELSEIF branch.

In either case, this is easily extended by just adding to the conditions/branches. It may look that it will take more CPU time, but this will hardly make any difference, but the maintenance effort is made much more bearable if done this way. And the computer is used to repetetive, monotonous work, humans normally are not.

Cor

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-
bounces@xxxxxxxxxxxx] On Behalf Of David FOXWELL
Sent: maandag 24 november 2008 11:15
To: RPG programming on the AS400 / iSeries
Subject: RE: Exiting a sub procedure

Hi,
Do you mean replacing something like this ( which is what I see often )
:......

IF NOT Control ()
RETURN *OFF
ENDIF

IF NOT Extract ()
RETURN *OFF
ENDIF

IF NOT Calculate ()
RETURN *OFF
ENDIF

IF NOT Output ()
RETURN *OFF
ENDIF

RETURN *ON


....by something like this?

RtnVar = *ON
IF NOT Control ()
RtnVar = *OFF

ELSEIF NOT Extract ()
RtnVar = *OFF

ELSEIF NOT Calculate ()
RtnVar = *OFF

ELSEIF NOT Output ()
RtnVar = *OFF

ENDIF

RETURN RtnVar



-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-
bounces@xxxxxxxxxxxx] De la part de Takken, Cor
Envoyé : lundi 24 novembre 2008 10:10
À : RPG programming on the AS400 / iSeries
Objet : RE: Exiting a sub procedure

I'd advice to re-engineer your procedure, this is a use-case for one of
my favourite stick-horses: only ever use one return per procedure. It
might result in one or more if-statements, but in that case you could
also write one subprocedure which determines which case to use and
write a dedicated subprocedure only handling one case. Clean, concise,
easily extendable and maintainable.

You could write a subroutine within the subprocedure to prevent
duplicate code (exsr handle-false or so), but if the handling code is
less than 3 lines that might be construed as overkill (however, in that
case bring forward that maintenance needs only be done in one place).

I don't know why debug ends up at the end-line of the subprocedure, I
have my suspicions (some hidden return-to-the-calling-opcode-opcode)
but I don't know.

My 2 eurocents,
Cor

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-
bounces@xxxxxxxxxxxx] On Behalf Of David FOXWELL
Sent: maandag 24 november 2008 9:37
To: RPG programming on the AS400 / iSeries
Subject: Exiting a sub procedure

Hello,

I'll be surprised if there's anything but NO to this question, but
I've
learned on this list that if you don't ask you don't learn so here
goes
anyway.

I have a subprocedure with many RETURN *OFF coded within. Now I need
to
add some code in the case of it returning *OFF. I think I have to
copy
this code before every RETURN *OFF. Is there anything that let's me
call another procedure on exiting this subprocedure? I just wondered
when debugging and noticing that RETURN *OFF seems to step to the
line
at the end of the sub procedure.
I don't want this code done by the calling procedures as they are
many
and external.

Thanks.
--
This is the RPG programming on the AS400 / iSeries (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 e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be
copied, disclosed to, retained or used by, any other party. If you are
not an intended recipient then please promptly delete this e-mail and
any attachment and all copies and inform the sender. Thank you.


--
This is the RPG programming on the AS400 / iSeries (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 AS400 / iSeries (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 e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.



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.