×
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.
There are multiple differences between a subprocedure and a subroutine.
1 - A subprocedure supports local variables. for example you could have X
defined as a 10 character field in the main body and as a 5 digit integer
in a subprocedure. Thus if you use the same subprocedure in multiple
programs you don't have to check the variable names. Not possible with a
subroutine.
2 - A subprocedure supports parameters, and, a return variable. For
example
x = MySubprocedure( a : b: c);
will set x equal to the value returned by the subprocedure MySubprocedure.
Sort of like building your own RPG bif's.
3 - You could copy in a subprocedure using /copy (like a subroutine)
however, many people chose to put the subprocedure into either a separate
module, or even into a service program. In this way it's poorly compared
to a completely separate CALLed program.
4 - Prototyping is a bit of extra work, which is why some people prefer
subroutines or, those that use both, will use subroutines for "simple"
stuff. However the prototyping adds a lot of capabilities. WDSC has
prototyping wizards.
5 - Sometimes for certain error processing routines or whatever and you
have to send out a program message using a send program message api some
people prefer subroutines because of the stack level. But that shouldn't
equate into an "all or nothing" decision as to the use of subprocedures.
See the manual "ILE Concepts".
I forced myself to use no subroutines for a few months and only use
subprocedures. Once I developed a comfort level by
- using them several times
- using parameters and the return variable
- building my own service programs
- building a multi module program
Then I felt that I could relax and use a subroutine on occasion if
"simplicity" or the call stack issue tugged at me.
Rob Berendt
As an Amazon Associate we earn from qualifying purchases.
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.