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


  • Subject: Re: RPGIV parameter validation
  • From: "Scott Klement" <infosys@xxxxxxxxxxxx>
  • Date: 08 Apr 1999 17:49:47 -0500

Heres how it works, as I understand it:

   When you put a prototype at the top of your program, and use
   that prototype, the compiler will make sure that each parameter
   to the procedure you're calling is of an acceptable type for
   that prototype.

   So, yes, this validates things as far as that goes.

   However...
      1) This is only helpful if the prototype matches the actual
         procedure definition.

      2) Using a "CALLB" instead of using the prototype will
         circumvent this mechanism altogether.  Likewise, calling
         it from a CL program with CALLPRC, or anywhere else that
         you don't use the prototype, will circumvent things.

      3) If you pass a pointer, it will validate that you're actually
         passing a pointer, but doesnt validate what kind of variable
         its pointing TO.

      4) When you pass something by value, the program will convert
         from one data type to another, if possible.  This could mean
         that decimal places are gained/lost.

      5) Character variables can be longer than the ones requested by
         the procedure, and if you specify options(*varsize) they can
         even be shorter.  There isn't any "danger" in passing a
         longer variable, but, with a shorter variable, it almost
         CERTAINLY needs to know this, and needs to deal with it
         appropriately.

      6) When validation occurs, it should be mentioned that it
         validates the types (and sometimes lengths) of the parameters
         but does *NOT* validate the VALUES of those parms.  Thats
         left up to your own program's logic.

I hope that clarifies (at least a little bit) what prototypes do,
and when they are helpful.

I personally think that the sub-procedures / prototypes are the BEST
addition made to RPG since external descriptions.  I mean, they REALLY
give you a lot of flexibility and allow you to modularize things
a LONG way beyond what was possible before.

Scott Klement
Information Systems Manager
Klement's Sausage Co, Inc.


Brian.Johnson@helpsystems.com wrote:
> I read in the RPG manual that using call prototypes allows the
>  compiler to
> validate the parameters.   Sounds great]  Then a colleague pointed o
>  that
> prototyped call parameters are NOT always validated.  Is this true?
>  What
> are the situations when the parameters are not validated?
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  Questions should *
* be directed to the list owner / operator: david@midrange.com          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


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.