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



Scott / Eric,

I think you missed the part where David said that the constant cX0 =
'X0' was already defined in the code by somebody else.

Which to him, me and you two of course makes little sense.

David added a constant with a long (and presumably meaningful) name.
Which is good.

The remaining issue IMO, is that he just added the meaningfully named
constant instead of replacing the meaningless cX0 constant.

Charles


On Fri, Sep 3, 2010 at 11:32 AM, Scott Klement
<rpg400-l@xxxxxxxxxxxxxxxx> wrote:
On 9/3/2010 3:59 AM, David FOXWELL wrote:
Working on a RPGIII that has just been converted to IV.
Need to test a field to see if its value is 'X0'.

So why not do this?

    IF Field = 'X0';
      //whatever
    endif;

Or in the older RPGIII-like syntax:

    C     FIELD1        IFEQ      'X0'

I guess I don't understand why you'd use a constant like cX0.  It
provides no clarity to the code -- in fact, it just makes the code
harder to read, because now you have to see what value cX0 contains...
whereas if you compare to the literal 'X0', it's obvious.

You should only use constants where the name of the constant CLARIFIES
it's meaning.

For example, you could change this:

   If Field1 < 5;

To this:

   If Field1 < MINIMUM_PRICE;


(or in RPGIII like syntax):

   C     FIELD1        IFLT      MINPRC

You now know what the 5 meant...  whereas before, you either had to
guess, or look for comments/documentation that explained it.  Naming the
constant something like c5 wouldn't have clarified anything, and
therefore would've been a waste of your time & the "next guy's" time.

The name of a variable/constant should never be a simple echo of it's
value.  That's pointless.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
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.