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



> > What is a Procedure?
> A re-usable piece of code, frequently in a *MODULE object, that performs
> a specific function and may or may not return a value.

I don't understand what you're trying to say here when you say "frequently
in a *MODULE object."   Everything is in a *MODULE object...

A procedure is, basically, callable code.   There are two types of
procedures:  "Main procedure" and "Sub-procedures."

The main procedure is the one with the *ENTRY PLIST.   If you've never
coded a subprocedure, then all of your code has been in a main procedure.
The main procedure is the one called automatically as part of the RPG
cycle.

Each module can have a separate main procedure.  If your program is made
up of many modules, you have to designate one main procedure as the
"entry procedure" to designate that this is the one that will be called
automatically when your program is activated by the CALL op-code.


> > What is a sub-procedure?
> Simplistically the same as a procedure.  Specifically it has no cycle,
> as defined by "nomain" in the H-Specs.

You can have subprocedures and "NOMAIN" without any conflict.   NOMAIN
means that you won't have a main procedure.  You can have both a main
procedure and subprocedures both in the same module without any problems.

A subprocedure is a "sub-program" or "function."  It's like a subroutine,
except that variables can be "scoped" so that they only exist in the
subprocedure.  It greatly improves testing & reusability if all variables
in a subprocedure only exist in that subprocedure.  You don't have to
worry about your main proc or other subprocs affecting the values of your
variables, therefore you don't have to re-rest each subprocedure when a
small change is made.   You can re-use the subprocedures in each program,
because unlike subroutines, you don't have to have particular global
variables set up in a specific way to use the subprocedure.

It also allows you to test the subprocedures independently.

You always know exactly what's affected...  the only variables that are
affected when you call a (well-written) subprocedure are the ones used
for parameters and return values.  And then, if you use CONST or VALUE,
you can make it clear that even less is affected.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.