|
A few possible solutions: 1) Use a return value instead of a parameter. Of course, that would require you to use subprocedures instead of programs. 2) Make the 2nd parameter be OPTIONS(*VARSIZE) of the maximum length, and add a 3rd parameter indicating the length of the variable. Then, make sure your "generic popup" program only touches as many bytes of the parameter as the number passed indicates. then you calling program would look like: callp lookup('TERMS': terms: %size(terms)) 3) do the same thing as #2, but instead of passing the length as a parm, calculate the length based on what the correct value would be for the data indicated by the first parameter. 4) Use a varying field (but then all of the programs calling it would also need to use varying, which isn't ideal IMHO) You mentioned OPDESC... I have very negative feelings towards OPDESC. It works for me MOST of the time, but every so often a program using OPDESC will suddenly not work because it can't find the operational descriptor. No rhyme or reason. Not only that, but OPDESC creates more complicated code than it's worth. On Thu, 31 Oct 2002, Reeve Fritchman wrote: > > 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
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.