|
Thanks to all who responded. This list is certainly a life saver. Happy Holidays to all. Rich --- Scott Klement <klemscot@klements.com> wrote: > > > On Sat, 1 Dec 2001, Richard Reeve wrote: > > > All, > > > > I am having a problem with an array in RPG > > (caused mainly by my ignorance where RPG is > concerned > > since I am a COBOL kind of guy!). What I am > trying to > > do is to read a file and load an array that will > have > > 2 elements - a legacy hold code (2 positions) and > a > > MHS hold code (2 positions). I then want to do a > > lookup on this array by MHS hold code and find the > > corresponding legacy hold code (later in the > program). > > > > Could someone be kind enough to coach me > through > > this? I will be forever greatful. > > > > Rich > > > > Here's the way that I'd do something like that... > > > FHOLDCODES IF E K DISK > > D MHS S 2A DIM(500) > D LEG S 2A DIM(500) > D ArraySize S 10I 0 > D Index S 10I 0 > D Result S 2A > D code S 2A > > ** Sample of loading the arrays from a file > ** > ** This assumes that you want to load the > whole file, and > ** that the two fields in the file are > "mhs_from_file" and > ** "legacy_from_file". > ** > ** You'll have to adjust it to fit the > details of your app. > > c *start setll HOLDCODES > c read HOLDCODES > > c dow not > %eof(HOLDCODES) > c eval ArraySize = > ArraySize + 1 > c eval MHS(ArraySize) = > mhs_from_file > c eval LEG(ArraySize) = > legacy_from_file > c read HOLDCODES > c enddo > > > > ** > ** Here is a sample of doing a lookup: > ** > ** The output of this will be that "Index" > will be set to the > ** position in the array of the matching > code, and indicator > ** 10 will be on when the lookup succeeds, > or off otherwise. > ** > ** Note that the "10" is in the "Eq" > position. This means we > ** are only looking up items in MHS that > are the same as > ** the contents of the "code" variable. > ** > C eval Index = 1 > c code lookup MHS(Index) > 10 > > c if *in10 = *Off > C* ... no matching code found ... > c else > c eval result = > LEG(Index) > c endif > > _______________________________________________ > This is the Midrange Systems Technical Discussion > (MIDRANGE-L) mailing list > To post a message email: MIDRANGE-L@midrange.com > To subscribe, unsubscribe, or change list options, > visit: > http://lists.midrange.com/cgi-bin/listinfo/midrange-l > or email: MIDRANGE-L-request@midrange.com > Before posting, please take a moment to review the > archives > at http://archive.midrange.com/midrange-l. > ===== __________________________________________________ Do You Yahoo!? Buy the perfect holiday gifts at Yahoo! Shopping. http://shopping.yahoo.com
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.