|
On 12/01/2006, at 4:45 AM, Lim Hock-Chai wrote:
When I call the above procedure with below, the piParm2 contains 'AAA' for all elements, any idea why?
Part of the problem is because you are passing a char(24) but you told the compiler the procedure expects a char(3) dim(8). When you use CONST on a parameter you cannot lie to the compiler. It will change your input parameter to match the prototype definition.
The weird part is that all 8 elements are populated with the first 3 characters from char24. However the same effect happens if you pass a CHAR(3) instead of CHAR(24) so I presume this is working as designed. The RPG IV documentation does say this is what will happen. See the Programmer's Guide under Parameter Passing Styles.
:quote.If the prototype requires an array of 4 elements, the passed parameter can be: o An array with fewer than 4 elements. In this case, the remaining elements in the received parameter will contain the default value for the type. o An array with 4 elements. In this case, each element of the received parameter will correspond to an element of the passed parameter. o An array with more than 4 elements. In this case, some of the elements of the passed array will not be passed to the received parameter. o A non-array. In this case, each element of the received parameter will contain the passed parameter value
:equote. The last point is the relevant one. Regards, Simon Coulter. -------------------------------------------------------------------- FlyByNight Software AS/400 Technical Specialists http://www.flybynight.com.au/ Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 /"\ Fax: +61 3 9419 0175 \ / X ASCII Ribbon campaign against HTML E-Mail / \ --------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.