× 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: How to create my own built-in functions
  • From: Scott Klement <klemscot@xxxxxxxxxxxx>
  • Date: Mon, 17 Jul 2000 15:18:34 -0500 (CDT)



On Mon, 17 Jul 2000, Buck Calabro wrote:

> You could certainly change the prototypes to "N" (indicator) if you wanted
> to.  I basically cribbed this quickie example from some existing code which
> used integer.    You can't use the form above with an integer data type -
> unlike C, RPG IV doesn't overload "Indicator" or "boolean" data types onto
> integers.  

I personally like to use integers as return codes.   Sure, if your goal is 
specifically to return a boolean value, an indicator would be better.  
For example something like IsDataValid()  would be better returning a
boolean value...

But with an integer you can return a lot of different things.  Lets say
for example, you're doing a  "RtvOrder()"  subprocedure.   You might have
a return value of "1" to mean it found the order, "0" that it couldn't
find the order (Which isnt necessarily an error) or "-1" to indicate that
that there was some sort of error.  (file not found, file damaged, etc)

I also (usually for debugging purposes) like to return different values to
help pinpoint where an error occurred.   Such as -1, -2, -3, -4 each
indicating a different error.   This way, my programs that don't care
WHICH error occurred can just check    if MyProc()<0   whereas those that
do care which error occurred can save that return code and act upon it.

So, although the indicator return value has its place -- its not NEARLY as
versatile as returning an integer is... thats my 2 cents on that :)


> 
> Also, as Scott pointed out, I have a dopey bug (I defined rc as unsigned
> integer when it should be SIGNED integer.  Thanks Scott!  Extra eyes make
> for fewer bugs!  I tested for the "successful" condition but not for the
> "failed" condition.  I gotta start paying closer attention to my own sig!)
> 

Hey... not a problem... thats the kind of mistake that everyone makes once
in awhile :)



+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

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.