× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 2/12/2016 8:22 PM, Brian Johnson wrote:
In #test_test wouldn't the assignment of '?' to parameter named input be
padding with 65534K blanks and overwriting who-knows-what in memory?


Exactly right. Here's what the manual says about *VARSIZE:

"When OPTIONS(*VARSIZE) is specified, the passed parameter may be shorter or longer in length than is defined in the prototype. It is then up to the called program or subprocedure to ensure that it accesses only as much data as was passed. To communicate the amount of data passed, you can either pass an extra parameter containing the length, or use operational descriptors for the subprocedure. For variable-length fields, you can use the %LEN built-in function to determine the current length of the passed parameter."

Bradley, if you just want the called procedure to be able to use the parameter's value, it would be much safer to make the parameter varying length. Then the called procedure could get the length by checking %LEN. If you want the procedure to get the trimmed value of the parameter, code OPTIONS(*TRIM), although that will trim both left and right.

If you want the procedure to be able to modify up to the full length of the passed parameter, I think your second parameter should be the size of the passed parameter, not the trimmed size. The procedure could figure out the trimmed length itself by using
%len(%trim(%subst(parm:1:parmsize)))


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.