|
I would try VARYING again. Set the prototype and the procedure interface in the program (you did say it was a *PGM you were calling, right?) to VARYING. If the *ENTRY/PLIST it the called program is a fixed-format *ENTRY/PLIST opcodes, then you're going to have issues. Instead, create the entry/plist using the PI statements for the program, something like this: D LOOKUP PI D parm1 10A D parm2 50A VARYING That should probably work, and use Len = %Len(parm2) to extract the length of the parameter passed to the program. Oh, and one more thing. Make sure you set the initial length of the parm to what you need, i.e., %len(parm2) = %size(sh_state) in the caller. -Cozzi -----Original Message----- From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com] On Behalf Of Reeve Fritchman Sent: Thursday, October 31, 2002 12:28 PM To: Rpg400-L@Midrange. Com Subject: Prototypes and parameters This is a multi-part message in MIME format. -- [ Picked text/plain from multipart/alternative ] I have a general-purpose pop-up window used to display and select values from a reference file. Parameter 1 is the reference name and it's passed in as a literal ('TERMS', 'STATE'). Parameter 2 is the field I want the value selected by the user returned into (back to the caller). Both parameters are 10A. Currently, the program is called with a prototype using EXTPGM('LOOKUP'). A typical implementation looks like this: C callp lookup('TERMS':q_alpha_10) C eval terms_code = %subst(q_alpha_10:1:%size(terms_code)) C callp lookup('STATE':q_alpha_10) C eval sh_state = %subst(q_alpha_10:1:%size(sh_state)) Now, the complication: the size of the second parameter varies (based on what I'm looking up): "terms_code" is 3A, but "sh_state" is 2A. Improper management of the parameters (size) has caused problems (decimal data errors because the improperly-sized parameter 2 overflows into adjacent fields in memory); the second line solved the problem. Because LOOKUP is called with EXTPGM, OPDESC doesn't work. Yes, it should be in a service program but circumstances of time and customer politics don't allow it. I've done this too: C callp lookup('TERMS':q_alpha_10) C eval terms_code = q_alpha_10 C callp lookup('STATE':q_alpha_10) C eval sh_state = q_alpha_10 This is the ideal solution: C callp lookup('TERMS':terms_code) C callp lookup('STATE':sh_state) I've tinkered with VARYING, setting the length, etc. but am unable to come up with a way to implement the ideal solution. Perhaps it's too much Halloween candy, but I'm sure there's a better way to juggle OPTIONS(*VARSIZE) and VARYING to make this work...or is there? Thanks, rf -- _______________________________________________ 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.