× 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 agree. Seeing 'For X = 1 To %Elem(CM#)', the meaning is immediately
obvious. The meaning of cCMLimit might not be immediately obvious,
particularly if naming and use standards aren't strict or non-existent.
I'd have to see the d-specs to know it's a constant and that it's used
to DIMension the arrays.

------------------------------

message: 7
date: Thu, 17 Aug 2006 10:48:25 -0400
from: "Jeff Crosby" <jlcrosby@xxxxxxxxxxxxxxxx>
subject: %Elem(Array) vs. cCMLimit

This isn't the most important question of our times, but I just wondered
what everyone else thought.

If I need to define more than one array, each array with the same number
of
elements, I typically do this:

D cCMLimit        C                   20

D CM#             S              7  0 Dim(cCMLimit)
D IN#             S              7  0 Dim(cCMLimit)
D AMT             S              7  2 Dim(cCMLimit)

Then, later in my code, I always use the constant I created, like this:

For X = 1 To cCMLimit;
  <do something>
Endfor;

Or this:

If X <= cCMLimit;
  <do something>
Else;
  <do something else>
Endif;

It suddenly occurred to me that even though I used a constant to define
the
size of the array, in the code I should still use %Elem like this:

For X = 1 To %Elem(CM#);
  <do something>
Endfor;

Because this makes it immediately apparent to any other programmer (or
me 6
months down the road) that I'm traversing the entire array, whereas
using a
constant doesn't imply that.

What do you think?

Enquiring minds want to know . . .


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.