|
On 05/03/2006, at 8:19 PM, Mike Pantzopoulos - (H/O) wrote:
I understood from the manual that the system converts the parameter passed from the calling RPG into a temporary vatiable length field if the prototype is declared as *varsize. In the calling RPG, the parameter can be declared as any length up to the prototype declaration. It's declared as a noraml variable, and If that's the case, then why can't they convert the CL variable in the same fashion and avoid this low-level explicitness?
Because the type conversion is performed by the RPG IV compiler. It uses the prototype definition to determine the appropriate target parameter type. This is done at the time of the compile. It is not a run-time function.
CL has no access to the function prototype and there is no easy way, even for the OS, to determine the type and attributes of a parameter thus because CL does not know anything about the function interface it cannot convert the parameters from one type to another.
In your case, you were passing a fixed-length variable (20 bytes) into a function that expected a varying length variable (22-bytes). Thus the function was interpreting the first two bytes of data as the varying length. For many data values this would result in a number larger than the maximum of 20 bytes the variable is capable of holding hence the exception.
Note also that you say *VARSIZE above but the variable that was causing the problem was *VARYING. These are not the same thing. *VARSIZE will work as expected between CL and RPG IV because CL passes the operational descriptor for character variables which includes the length of the passed data. As long as the receiving procedure correctly retrieves the operational descriptor and limits its operations on the variable to the length specified in the operation descriptor everything will work as expected.
CL has no direct support for *VARYING character strings so these must be built by the programmer using the method I described previously.
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-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.