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



If I'm traversing an entire array, I always try to use the %Elem().
However, there have been times when I have created constants for each array
element. For example,

Elem 4 would hold company total,
Elem 3 would hold region
Elem 2 would hold area
Elem 1 would hold unit.

Then I would code my loop as

for Location = Unit to Comp
   Array(location) ...
EndFor;



Try our New Country Benedicts -- Breakfast with a Bob Evans twist!



                                                                           
             "Jeff Crosby"                                                 
             <jlcrosby@dilgard                                             
             foods.com>                                                 To 
             Sent by:                  "'RPG programming on the AS400 /    
             rpg400-l-bounces+         iSeries'" <rpg400-l@xxxxxxxxxxxx>   
             michael_schutte=b                                          cc 
             obevans.com@midra                                             
             nge.com                                               Subject 
                                       %Elem(Array) vs. cCMLimit           
                                                                           
             08/17/2006 10:48                                              
             AM                                                            
                                                                           
                                                                           
             Please respond to                                             
              RPG programming                                              
              on the AS400 /                                               
                  iSeries                                                  
             <rpg400-l@midrang                                             
                  e.com>                                                   
                                                                           
                                                                           




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

--
Jeff Crosby
Dilgard Frozen Foods, Inc.
P.O. Box 13369
Ft. Wayne, IN 46868-3369
260-422-7531

The opinions expressed are my own and not necessarily the opinion of my
company.  Unless I say so.


--
This is the RPG programming on the AS400 / iSeries (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 ...

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.