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





-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of
AGlauser@xxxxxxxxxxxx
Sent: Tuesday, October 09, 2007 12:45 PM
To: RPG programming on the AS400 / iSeries
Subject: RE: will v6r1 RPG support main procedure recursion?


Duane Christen wrote on 09/10/2007 13:30:29:
Here is the full source.
http://code.midrange.com/3fdd57c9f0.html

Thanks for sharing your example of subprocedure use within a
subroutine.
In another post, you said

I could have the subroutines as procedures, and honestly
I would have no objection in this case. But the code in
these subroutines is not, can not, and will not be used
elsewhere so what is the point of creating a procedure
where a subroutine works just fine.


If the code in the subroutines can't be used in any other
context than a
specific place that specific procedure, I don't see the value
in putting
it in a subroutine in the first place. I think it really is just a
stylistic preference in this case. Given the example above,
I probably
would have delineated the subroutine portions of the code
with a comment
block instead of putting it in a subroutine.

Did that all the time with C, I like subroutines better. As you say this is
all probably just style, personal taste.


In yet another post, you alluded to initialize / cleanup
subroutines that
get put in 90% of the subprocedures you write. What is the
benefit of
using subroutines in that situation as opposed to subprocedures?


In this case there is code to initialize internal structures for message
handling, condition handler(s), jmp/longJmp (C Functions which are glorified
GOTOs) and internal/local initializations.

Here is an example: http://code.midrange.com/ec1f7b640a.html

I build two general types of procedures, API-procedures and simple
procedures.
Simple procedures do one thing, generaly in less than a page of code. They
do very little initialization/validation if any and they either work or they
fail. Like this:
/Free


If %Parms = 1;
errNoBase = errNo_BuiltIn();
errNoValue = setErrNoValue;
EndIf;

errNoBase = errNo_BuiltIn();

Return errNoValue;

/End-Free


Where as the code http://code.midrange.com/ec1f7b640a.html is built as an
API.
These procedures send exception messages to themselves, where the condition
handler picks them up and places the relevant information into the usec
error structure (same as the system error structure) and returns to the
setJmp() point in the procedure(program). The usec error structure gets
passed back to the caller which decides what to do with it.

This could be done inline too, but they would not make very good
subprocedures because of all the local vars that they need.

Duane Christen




NOTICE: This electronic mail transmission may contain confidential
information and is intended only for the person(s) named. Any use, copying
or disclosure by any other person is strictly prohibited. If you have
received this transmission in error, please notify the sender via e-mail.




As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.