|
Tim,Please explain why you've coded the word "VARYING". It doesn't make sense to me. I think you're misinterpreting what VARYING does.
--- Scott Klement http://www.scottklement.com On Thu, 9 Feb 2006, Tim Kredlo wrote:
O Wise (and Generous With Your Help) List Members, Help again!! I have declared two pointer based data structures Dlr & Dlr1) as 100A, each DIMmed to 2500 initial elements and as VARYING. I created a user space for each with an initial size of 1,000,000 and retrieved their pointers, which are used to base Dlr & Dlr1. Declarations: D DlrDs Ds Qualified D Idx Like(A_10) D Code Like(A_1) D Type Like(A_1) D Grp# Like(A_6) D Dlr# Like(A_6) D Name Like(A_40) D Stat Like(A_10) D City Like(A_20) D Ds Based(DlrBase) D Dlr 100A Varying D Dim(2500) D Ascend D DlrIdx Like(DlrDs.Idx) D Overlay(Dlr : 1) D DlrCode Like(DlrDs.Code) D Overlay(Dlr : *Next) D DlrType Like(DlrDs.Type) D Overlay(Dlr : *Next) D DlrGrp# Like(DlrDs.Grp#) D Overlay(Dlr : *Next) D DlrDlr# Like(DlrDs.Dlr#) D Overlay(Dlr : *Next) D DlrName Like(DlrDs.Name) D Overlay(Dlr : *Next) D DlrCity Like(DlrDs.City) D Overlay(Dlr : *Next) D DlrStat Like(DlrDs.Stat) D Overlay(Dlr : *Next) Dlr1 is declared identically, except for the sub-field names and basing pointer. The sum of the length of the sub-fields is 94, but I set Dlr and Dlr1 to 100 to hold the 'hidden' integer Bob Cozzi indicated was inserted at the beginning of 'varying' arrays and/or data structures. I ran the program in debug (StrDbg). I filled 1821 elements of Dlr1 from files. At the end of the fill procedure, I tested Dlr1(1821) and it contained expected values. Dlr1(1822) was empty as expected. Because I had previously received the RNX0115 message, I evalled Dlr1(2501) and it was displayed as empty. I had expected an error since it had been DIMmed to 2500 elements, which I had thought would be the limiting number. I then continued to test and found that eval would display empty values up to and including Dlr1(9834), but returned the following error when I evalled Dlr1(9835): Error on operand value. I evalled Idx and it was correctly set at 1821. (9834 is the integer result of 1,000,000 / 102) (102 is the declared 100 plus the 2 byte integer.) The next statement: %SubArr( Dlr : 1 : Idx ) = %SubArr ( Dlr1 : 1 : Idx ); Resulted in the following error: Message ID . . . . . . : RNX0115 Severity . . . . . . . : 50 Message type . . . . . : Diagnostic Date sent . . . . . . : 02/09/06 Time sent . . . . . . : 10:09:36 Message . . . . : Length of varying length variable is out of range. Cause . . . . . : The length of a varying length character or DBCS variable is less than 0 or greater than its declared maximum length in RPG procedure INITIALIZE in program EXPRDPGM/PICKCUSTN. I am going to use the method(s) Charles Wilt (Thanks again, Charles) had suggested to accomplish my sort, but would really like to understand what is going on here. Why does Dlr1 now have 9834 elements? Does DIMming an array not limit the maximum number of elements it can have? If not, why not DIM all varying arrays to '2'? How can one 'ever' avoid the RNX0115 error if the varying arrays are going to automatically use all allocated memory? I am at V5R3, PTF'd as: SF99530 5207 Installed SF99529 65 Installed SF99503 7 Installed SF99298 15 Installed SF99269 7 Installed SF99185 9 Installed SF99139 2 Installed SF99099 7 Installed Thanks in advance for any explanations or directions to relevant information. Tim Kredlo -- 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 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.