× 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.



Brad:

ILE RPG IV supports "Operational Descriptors" to help with these issues. Look for the "OPDESC" keyword on these pages:

See:
http://www.itjungle.com/mgo/mgo052902-story01.html

See also:
http://www.nicklitten.com/blog/interesting-rpg-ile-code-example

Google for "os/400 operational descriptors in ile rpg iv" (without quotes) to find additional references.

Using only naked unconstrained pointers abandons any protections offered by RPG IV with the use of procedure prototypes and opens programs to possible "storage overlays" -- the most insidious, difficult to diagnose, hard to debug problems you could ever ask for.

Hope that helps,

Mark S. Waterbury

> On 2/12/2016 11:48 PM, Bradley Stone wrote:
Wow.. thanks for the responses! Makes sense to me... I missed that last
part in the docs.

I guess I just assumed there was more automation going on in the background
with *VARSIZE.

The issue is the length could be 1 to anything. What if I wanted to pass
back more than the full length declared? That sounds like it's not going
to work. I may need to move to just using pointers instead.



On Fri, Feb 12, 2016 at 9:57 PM, Barbara Morris <bmorris@xxxxxxxxxx> wrote:

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)))

--
Barbara


--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.



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.