String Parameters of Various Lengths, Take Two
June 12, 2002 Timothy Prickett Morgan
Dear Readers:
Several people have written to point out errors in my solution to the reader who wanted to make an RPG subprocedure accept character parameters of any size. I need to correct the code that I provided in that issue of Midrange Guru, OS/400 Edition. (I plan to explore this topic more and to present the ideas of my respondents in the near future, so watch for more information in a future edition of Midrange Guru.)
Here is the original question”
“I have an RPG IV subprocedure that I call from several different programs. I use what I call the QCMDEXC method to pass a character string to it. That is, I pass two parameters–the character string and the length of the character string. I would like to eliminate the second parameter.”
I failed to explain that the subprocedure needed to modify the string parameter. I made the mistake of including the CONST keyword on the string parameter while testing, but forgot to remove it before publication. As my demo subprocedure did not modify the string, the compiler did not catch my error.
Here is the proper code (I hope).
First, the procedure prototype:
D MyProc PR Opdesc D String 32767 Options(*Varsize)
Next, the subprocedure:
H nomain /copy copysrc,myproc /copy copysrc,ceedod P MyProc B Export * Procedure Interface D PI Opdesc D String 32767 Options(*Varsize) * Variables for the CEEDOD API D DescType s 10I 0 D DataType s 10I 0 D DescInfo1 s 10I 0 D DescInfo2 s 10I 0 D DataLen s 10I 0 * Retrieve the length of the string parameter C Callp CEEDOD(1: DescType: C DataType : DescInfo1: C DescInfo2 : DataLen : C *OMIT) * DataLen now contains the length of the input string * Do whatever needs to be done C Return P e
I apologize for the error.
— Ted
Sponsored By ADVANCED SYSTEMS CONCEPTS |
SEQUEL meets all your iSeries and AS/400 data access needs in a single, integrated solution:
Take 6 minutes to For more information or a FREE trial of SEQUEL, |