× 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: %BIF for "abc < 0" & new figurative constants
  • From: "Bale, Dan" <DBale@xxxxxxxxxxxxxxxx>
  • Date: Wed, 8 Mar 2000 11:46:57 -0500

First of all, I am NOT the subject of this thread!  ;-)  Hence I have
renamed it.

Gary, I think I see where you're going with this.  And I noticed you
qualified your suggestion that it "might" be useful.

However, with all due respect, and humbly recognizing that there are far
greater minds on this topic than I possess...

If you're suggesting that Hans & Company create the additional figurative
constants like you suggested, I've no real problems with that.  The key for
me is that every AS/400 at a certain minimum OS/400 release will handle
*Negative in exactly the same way.  However, what happens if there's a
fourth (or more) condition you need to test for?  My experience with return
codes is that they are either -1, 0, or a value > 0 of which there may be
several possible values.

Getting back to the pseudo-original topic, IMVHO, I see a danger in creating
BIFs like %Negative, especially when you replace one simple and
understandable native RPG expression (i.e., "abc < 0") with a home-brewed
BIF (i.e., "%Negative(abc)").  You said that you didn't see a "huge
advantage" for this BIF; did you really see _any_ advantage for it?  If _I_
write the %Negative BIF, _I_ know exactly what it's doing.  If I leave the
shop for another, and someone comes in after me and finds this code in a
program, the first thing he's going to ask is "What's this %Negative BIF
do?".  Then he looks for the service program source, finds the procedure,
and scratches his head, "What was he thinking?".  Conversely, everyone
understands what "abc < 0" means.

If the %Negative BIF idea was simply intended as a practice exercise to
learn ILE, procedures, service programs, BIFs, etc., that would be a good
start.  However, I would prefer not to see this in production code.

Still learning after all these years...
- Dan Bale

-----Original Message-----
From: Gary Guthrie [mailto:GaryGuthrie@home.com]
Sent: Tuesday, March 07, 2000 6:07 PM
To: RPG400-L@midrange.com
Subject: Re: Bale, Dan

Dan,

Here's your education. :)

I don't see a huge advantage for a BIF for abc < 0. If it floats
somebody's boat, then ok.

The feature that I would argue could be useful for clarity is a
figurative constant *NEGATIVE. Let me give you an example.

Consider that you might have a procedure with a Boolean return value to
indicate success (*Off) or failure (*On) . You could then code something
like:


C              If       MyProc( MyParm )
 * Perform error processing
C              EndIf

or you might

C              Eval     RtnCode = MyProc( MyParm )
C              Select
C              When     RtnCode = *Off
 * Perform normal processing

C              When     RtnCode = *On
 * Perform error processing

C              EndSl

This kind of construct works fine for 2 conditions - normal vs. error.
However, the procedure might want to return multiple conditions where
negative numbers were various error conditions, zero means new customer,
and positive numbers mean existing customer of some sort. Here's an
example of how you might do this:

C              Eval     RtnCode = MyProc( MyParm )
C              Select
C              When     RtnCode > *Zero
 * Perform existing customer processing

C              When     RtnCode = *Zero
 * Perform new customer processing

C              When     RtnCode < *Zero
 * Perform error processing

C              EndSl

I submit it might be clearer to:

D Error        S      N  Inz( *Negative )
D ExistingCust S      N  Inz( *Positive )
D NewCust      S      N  Inz( *Off )

C              Eval     RtnCode = MyProc( MyParm )
C              Select
C              When     RtnCode = ExistingCust
 * Perform existing customer processing

C              When     RtnCode = NewCust
 * Perform new customer processing

C              When     RtnCode = Error
 * Perform error processing

C              EndSl

or something like that.

Gary Guthrie



"Bale, Dan" wrote:
> 
> Gary, David, Paul, ...
> 
> Please educate me on this.  I'm having a hard time seeing the value of
> creating a BIF when a simple "If  abc < 0" will (should?) suffice.
+---
| 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:

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.