|
Hello,way
Understand, I normally prefer to use OPDESC to figure out the length
when possible. Why make all the callers do the work when there is a
theto figure it out internally ;).
I'm trying to understand the scenario... I'm envisioning that you
have multiple "exported" procedures available to the caller, and all
need to call an "internal" procedure and pass this data on to the
internal procedure.
The problem is, when you call the internal procedure, RPG populates
OPDESC with what THAT PROCEDURE knows about the variable instead ofwhat
the caller provided in it's opdesc. So if you have a 32k VARYING, itfrom
passes 32k as the length, even if the caller only told you it was 4k.
(For example)
So... why use an OPDESC when calling the internal procedure? Why not
retrieve the length in the caller, and pass it as a parameter to the
internal procedure? Since that procedure is never called directly
the outside, there's no extra effort required by the caller. Theextra
effort is only required internally...
The alternative (and the way I usually do stuff like this) is to use a
VARYING string. Then RPG passes the length in the first two bytes ofnon-varying
the string itself. If you want callers to be able to pass a
string, use CONST on the parameter, and RPG will automaticallytransform
it to a VARYING and automatically set the length appropriately.above.
The disadvantage is that you can't use that for RETURNED values. For
returned values, I'd use the OPDESC approach instead, as outlined
Unfortunately, that also means you need multiple front-ends if you
want to support both fixed-length and VARYING...
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.