|
On Wed, 26 Nov 2003, Bob cozzi wrote: > The problem I have with this technique is that is _requires_ your input > string to be a VARYING field. It will not accept a traditional, fixed-length > field that does not include the VARYING keyword. You mean that the OUTPUT is required to be VARYING, right? The input parmeter is CONST so it can be anything, but you're right about the output string, it must be VARYING. That's one disadvantage to this technique. > So you end up having to make a choice VARYING or NON-varying support for > the function. I wish it would work without the need for CONST or VALUE > but that is the only way a VARYING parm will accept a non-VARYING field > and vis versa. So, you have two procedures -- one that outputs VARYING and another that just outputs a standard string with *VARSIZE. You could even have one of them be a wrapper that calls the other. For example: * * Test proc to call for non-varying fields * P TSTPRC1 B D TSTPRC1 PI D $InpStr 255 varying const D #RtnStr 65535A options(*varsize) D RtnStrSize 10I 0 value c eval %subst(#RtnStr:1:RtnStrSize) = c $InpStr c return P E * * Wrapper around TSTPRC1 for use with VARYING fields. * P TSTPRC2 B D TSTPRC2 PI D $InpStr 255 varying const D #RtnStr 65535A varying options(*varsize) D RtnStrSize 10I 0 value D p_Data s * D Data s 65535A based(p_Data) c eval RtnStrSize = RtnStrSize - 2 c if %len($InpStr) > RtnStrSize c eval %len(#RtnStr) = RtnStrSize c else c eval %len(#RtnStr) = %len($InpStr) c endif c eval p_Data = %addr(#RtnStr) + 2 c callp TSTPRC1($InpStr: Data: %len(#RtnStr)) c return P E
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.