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



I use a small c for constants. The standard has been all upper case but I
prefer to have all fields coming from files to be upper case so I end up
with something like this

B_CUSTNUM = DBFIELD1;

d cNumberOfWeeksInYear...
d c 52

WorkField = DBFIELD2 / cNumberOfWeeksInYear;

As far as global or local I put a constant local if it only going to be used
in that procedure. The closer the better and put it global if it will be
used in mulitple procedures. Does not matter where you put them. They don't
take storage and are not executable code.

I would agree that making a constant unreadable makes no sense.

Amazing thing is that there are actually people who use named constants.
Everyone I have ever known just puts AField = 52;. What the hell is 52 but
most places including the current the programmers would have a fit it they
had to identify a constant. I am the only person who ever did it.

On Wed, Apr 1, 2009 at 6:58 AM, David FOXWELL <David.FOXWELL@xxxxxxxxx>wrote:



-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Charles Wilt

* Global figurative constants
* Type relation = aunt
D gA C 'A'

myRelation = gA;


That's just plain silly.

Of course it is. Any advice on how to break the news to the person who
wrote it?


I tend to tie the constant value to the field:
d RELATION_AUNT
d c 'A'
d RELATION_UNCLE
d c 'U'


I like that too. I did have the same, but when I saw my code :

TypeRelation = RELATION_AUNT;

I decided to reduce my constant name to AUNT to avoid repetition.

One could argue that a constant should never be local. As
that would allow you to have different definitions of it in
different procedures.
Which defeats the purpose of a constant.

We have one programmer who likes to make everything local where possible.
In the case of a constant, it would be changed to global as soon as another
procedure needed the same constant.

How about this for a rule ? :
All constants declared directly in the source are local.
All global constants must be in a copy book.

The idea being to use standard definitions wherever possible.

Thanks, Charles.
--
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.