× 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'm coding my first dynamic array into an rpg application (thanks to the
example code provided in an email to this list by Scott Klement).  From
reading the IBM help, it appears that "The newly allocated storage is
uninitialized."   So, I'm initializing the new elements that I'm adding
to the array.  Is this standard practice?  Do I need to do this if I use
the keyword INZ on the array definition?  Is there any way I can
automate the initialization through a keyword instead of using the FOR
loop in the subroutine below?

 * Allocate the Item Array.    
 *  ItmAryMax is updated     
CSR   AllocItmAry   BegSr                                             

C                   Eval      ItmAryMax += ItmAryIncr
                                                                      
 *  If the current max array size equals the array increment value,   
 *  then we need to perform the initial allocation of the array.      
C                   If        ItmAryMax = ItmAryIncr                  
C                   Eval      p_ItmAry = %alloc( ItmAry_LEN * ItmAryMax)
                                                                      
 *  If they are not equal, then we are allocating additional space for
 *  the array.                                                        
C                   Else                                              
C                   Eval      p_ItmAry = %realloc( p_ItmAry :         
C                                        (ItmAry_LEN * ItmAryMax) )   
C                   EndIf                                             
                                                                      
 *  Allocation of memory doesn't initialize memory.                   
 *  Initialize the allocated memory. Start in 1st position allocated  
 *  (The max - the increment results in the last position used, or in 
 *  the case of new initialization, 0, so add 1 to the first position to

 *  initialize).

C                   For       x = (ItmAryMax - ItmAryIncr + 1) to
ItmAryMax 
C                   Clear                   ItmAry( x )

C                   EndFor

 

CSR                 EndSr

 
Kurt Anderson
Application Developer
Highsmith Inc.
W5527 State Road 106, P.O. Box 800
Fort Atkinson, WI 53538-0800
TEL (920) 563-9571  FAX (920) 563-7395
EMAIL kjanderson@xxxxxxxxxxxxx
 

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.