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



Himanshu,

Are you asking for something like REDIM in Visual Basic, where you can
redimension an array on the fly (and preserve the existing array elements
if you want to)?  The RPG gurus in my shop say it can't be done, but I'm
hoping someone here can prove them wrong.

Mike E.





                    "Himanshu Mohan,
                    Gurgaon"                To:     rpg400-l@midrange.com
                    <himanshum@ggn.hc       cc:
                    ltech.com>              Subject:     RE: Dynamic Arrays
                    Sent by:
                    rpg400-l-admin@mi
                    drange.com


                    10/16/2002 09:25
                    AM
                    Please respond to
                    rpg400-l






If you execute DO loop to 20001 instead of 50 times, this program will give
error because array dimension is fixed at 20000. program is allocating more
memory to array but it dimensions is fixed to 20000. I want to increase its
dimension at run time from 20000.

Himanshu

-----Original Message-----
From: MWalter@hanoverwire.com [mailto:MWalter@hanoverwire.com]
Sent: Wednesday, October 16, 2002 5:39 PM
To: rpg400-l@midrange.com
Subject: Re: Dynamic Arrays



define the array as based. Here is an example.
?     * array definitions
     Darray            S             10    DIM(20000) BASED(PTR)
     Dindex            s              7  0
?     * memory allocation data items
     Dptr              S               *
     Dnbr_of_elems     S              5  0 INZ(10)
     Dmem_size         S              7  0 INZ
     Dx                S             10i 0
?     * allocate the initial memory heap (initial # of elements * the size
of the array)
     C                   EVAL      mem_size = %size(array) * nbr_of_elems
     C                   ALLOC     mem_size      ptr
     C                   EVAL      x = %elem(array)
?     * loop to test
?    C     1             DO        50            index
?     * does the index exceed the current # of array elements?
?    C                   IF        index > nbr_of_elems
?     * recalculate the memory heap size by adding 10 to the number of
elements
?     * and multiplying the size of the array by the new number of
elements.
     C                   EVAL      nbr_of_elems = nbr_of_elems + 10
     C                   EVAL      mem_size = %size(array) * nbr_of_elems
?     * reallocate the memory heap and increase the size
     C                   REALLOC   mem_size      ptr
?    C                   ENDIF
?     * move data for test
     C                   MOVE      index         array(index)
?     *
?    C                   ENDDO
?     * deallocate the memory utilized
     C                   DEALLOC                 ptr
     C                   EVAL      *inlr = *on

Thanks,

Mark


Mark Walter
Sr. Programmer/Analyst
Hanover Wire Cloth a div of CCX, Inc.
mwalter@hanoverwire.com
http://www.hanoverwire.com
717.637.3795 Ext.3040

_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
or email: RPG400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
or email: RPG400-L-request@midrange.com
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 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.