|
Help! I am having difficulty accomplishing the following: I need to create and fill a data structure that will hold an array of up to approximately 2500 elements. The exact number will not be known until run time. Each element of the array will be like (likeds) a 94 character data structure. I need to be able to resize the 2500 element data structure to remove any unfilled elements. I need to be able to sort the data structure by any of the sub-fields. This is what I have done so far: Declared a data structure 'template' for each element of both arrays (Dlr and Dlr1): D DlrDs Ds Qualified D Idx Like(Int10) D Code Like(CsRecd.CsDele) D Type Like(A_1) D Grp# Like(CsRecd.CsGrp#) D Dlr# Like(CsRecd.CsDlr#) D Name Like(CsRecd.CsName) D Stat Like(DaRecd.DaStat) D City Like(DaRecd.DaCity) A_1 is declared as 1A CsRecd.CsDele is declared as 1A CsRecd.CsGrp# is declared as 6P 0 CsRecd.CsDlr# is declared as 6P 0 CsRecd.CsName is declared as 40A DaRecd.DaStat is declared as 10A DaRecd.DaCity is declared as 20A Declared 2 pointers: D DlrBase S * Inz D DlrBas1 S * Inz Declared two data structures based on the above pointers: D Ds Based(DlrBase) D Dlr 94A 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) D Ds Based(DlrBas1) D Dlr1 94A Dim(2500) D Ascend D Dlr1Idx Like(DlrDs.Idx) D Overlay(Dlr1 : 1) D Dlr1Code Like(DlrDs.Code) D Overlay(Dlr1 : *Next) D Dlr1Type Like(DlrDs.Type) D Overlay(Dlr1 : *Next) D Dlr1Grp# Like(DlrDs.Grp#) D Overlay(Dlr1 : *Next) D Dlr1Dlr# Like(DlrDs.Dlr#) D Overlay(Dlr1 : *Next) D Dlr1Name Like(DlrDs.Name) D Overlay(Dlr1 : *Next) D Dlr1City Like(DlrDs.City) D Overlay(Dlr1 : *Next) D Dlr1Stat Like(DlrDs.Stat) D Overlay(Dlr1 : *Next) I had hoped that I could have declared these using 'likeds', but I don't think I could have made them 'varying' or been able to sort by the sub-fields. Please tell me I am wrong about that, because it sure would make maintenance easier. What I would really like to be able to do is "SortArray (QlfdDs((QlfdDs.Field1:Ascend)(QlfdDs.Field2:Descend)))". (In my dreams) I then created 2 user spaces, initialized with blanks('x'40') and retrieved their pointers (DlrBase and DlrBas1). I filled elements of Dlr1, the non-varying array, from files till done and kept the number of elements filled (Idx = 1820 today). The following statement was then executed to fill Dlr and resize it to only contain the filled elements: %SubArr( Dlr : 1 : Idx ) = %SubArr ( Dlr1 : 1 : Idx ); Immediately after that statement was executed, debug evals showed the following: > EVAL dlr1(1) DLR1(1) = ....5...10...15...20...25...30...35...40...45...50...55...60 1 ' -AA000000000050MISCELLANEOUS ' 61 ' ' > EVAL dlr(1) DLR(1) = ....5...10...15...20...25...30...35...40...45...50...55...60 1 ' -AA000000000050MISCELLANEOUS ' 61 ' ' I don't know if the e-mail formatting will show this correctly, but the end "'" for DLR(1) is in position 95 and the end "'" for DLR(1) is in position 97. I then did the following debug evals: > EVAL dlr1name(1) DLR1NAME(1) = 'MISCELLANEOUS ' > EVAL dlrname(1) DLRNAME(1) = '50MISCELLANEOUS ' Notice that the two data structures (Dlr and Dlr1) are declared identically, but the DlrName field now appears to start 2 characters prior to Dlr1name field. I thought that perhaps this was an 'align' issue, so stuck 'align' on the declaration for both Dlr and Dlr1 and recompiled. (I don't know if there is more that I would need to do.)There were no warnings in the compile listing about mis-aligned fields. I re-ran and received the same results. I am stuck as to where to look next. All code and debug info was 'cut and pasted' into this email. So if you see what appears to be a typo, it is probably wrong in my code and needs to be pointed out. Thanks in advance for any help.
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.