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



This is a multi-part message in MIME format.
--
[ Picked text/plain from multipart/alternative ]
Buck,

With procedures you do get the advantage of the keyword OPTIONS(*NOPASS)
that allows a parameter to be left off of the parameter list. But if you
do not use that keyword, the compiler does parameter checking at compile
time, requiring you to specify the parameter, thus allowing you to avoid
a runtime error.

FYI, you can also use this type of thing when calling programs so this
advantage as it relates to procedures isn't there.

Bob



-----Original Message-----
From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com]
On Behalf Of Buck Calabro
Sent: Monday, November 18, 2002 11:51 AM
To: rpg400-l@midrange.com
Subject: RE: What's the difference?



>I was coming from the stand point of

>if program A called program B with 0

>(zero)parameters, but program B was

>expecting 1 parameter then program B

>would come up with a "pointer not

>set for location reference" error when

>that field was referenced;



If we're talking about a program that does NOT use %parms, and a

subprocedure that does NOT use %parms, the behaviour you describe is

identical in procs and progs.  That is, if the called code does NOT

explicitly check to see how many parameters have been passed, then that
code

will have Bad Things happen when it references the non-passed parameter.



I say Bad Things, because you may have a stale pointer left on the
stack,

and NOT get a MCH3601, but some other unpredictable failure as the
called

code works on some other part of memory it doesn't own.



If we're talking about a program uses that %parms, it most certainly can

restrict reference to the non passed parameters just as a subprocedure
that

uses %parms can.  An earlier reply had a code snippet from a working
program

that demonstrates this.



That's why I feel that subprocedures do not offer more functionality
over

programs in this particular.



There was a reply about *OMITting a parameter in the middle of a list,
but I

honestly have never seen a need to do that in a subprocedure and so
freely

admit to ignorance of how to implement it in a called program.  I also

freely admit to not being the brightest bulb in the pack.  Perhaps
there's

more demand for this than I ever thought of in my limited experience.

Something to keep in mind when comparing procs to progs though.

  --buck

_______________________________________________

This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list

To post a message email: RPG400-L@midrange.com

To subscribe, unsubscribe, or change list options,

visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l

or email: RPG400-L-request@midrange.com

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

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.