|
In V5Rx (5.1 I think) the LIKEDS keyword does what we wish the old LIKE keyword did. That is, it actually declares another data structure with the same subfields as the based-on data structure. Whereas the old LIKE keyword simply created a character field with the same length as the data structure--no subfields included. :( This was the only way to do this kind of thing, until V5, however. Bob Cozzi -----Original Message----- From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com] On Behalf Of Haas, Matt Sent: Thursday, November 07, 2002 8:42 AM To: rpg400-l@midrange.com Subject: RE: subprocedure questions Dan, If you look (and unless I mis-keyed something) both data structures are the same except for the names. The reason for this was to give the subprocedure it's own copy of the data structure to work with so you don't run into problems with scope. I could have easily updated the variables in MyDS directly, eliminating the need to even return anything but that's a bad thing to do since it makes the code very hard to debug, but this keeps it more modular so if you need to, it can be broken out into a service program. Matt -----Original Message----- From: Dan [mailto:dbcerpg@yahoo.com] Sent: Thursday, November 07, 2002 9:28 AM To: rpg400-l@midrange.com Subject: RE: subprocedure questions I'm going to give that a try. Question: In your PI (Procedure Interface), you use LIKE(MyDS), but the data structure below defines MyDS2. Was that intentional? Or would you just as soon use MyDS2? Does the subprocedure "see" all the variables in the main module? TIA, Dan --- "Haas, Matt" <Matt.Haas@thomsonlearning.com> wrote: > Dan, > > There's two way's to do this, the first is to remove the 'VALUE' from > Z_ACGAMT and Z_AMTERR which passes the variable by reference instead > of by value so you can modify it in your subprocedure. Passing by > value (which is what you do when you add VALUE to a parameter > definition) is similar to declaring a constant in that you can't > change it in the subprocedure. > > A better way would be to create a data structure for these two values > and return the data structure just like you would when dealing with > API's. This makes the program much easier to maintain if you need to > return another field in the future. To do this, you'd do something > like this: > > DMyDS DS > D Z_ACGAMT 8S 2 > D Z_AMTERR 30A > > > D CVTA2N PR LIKE(MyDS) > D ACGAMT 10A VALUE > > C eval MyDS = CVTA2N(ACGAMT) > > P CVTA2N B > D CVTA2N PI LIKE(MyDS) > D ACGAMT 10A VALUE > > DMyDS2 DS > D X_ACGAMT 8S 2 > D X_AMTERR 30A > <snip> > C ......... EVAL X_ACGAMT = N_ACGAMT > C ......... RETURN MyDS2 > P E > > Matt __________________________________________________ Do you Yahoo!? U2 on LAUNCH - Exclusive greatest hits videos http://launch.yahoo.com/u2 _______________________________________________ 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 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.