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



Brian,

When you pass a parameter by reference (default), all that is actually passed is the pointer to the parameter. If you don't specify OPTIONS(*VARSIZE) the compiler checks whether the parameter you are passing matches the length that is defined in the prototype. If you do specify OPTIONS(*VARSIZE), you tell the compiler that it does not have to check the length. Obviously the procedure has to have a way to know the actual length of the parameter being passed. One way is to have an extra parameter for the length (as most APIs have); another way is to use a VARYING length parameter.

Joep Beckeringh


brian wrote:
I'm writing a procedure that's a nicer interface to cvthc. cvthc's
parameters are two pointers and an integer. In the fields of my
procedure's prototype, I don't want to specify some arbitrary field length
limit. I basically want to pass two pointers and an integer indicating the
length of one of the fields. I originally coded it exactly like that, but
the caller has to specify %addr(source), etc. I'd like to avoid that.

I'm looking at changing the source and destination fields to be
options(*varsize), but there is a strange detail. The V5R2 RPG manual says
"When OPTIONS(*VARSIZE) is specified, the passed parameter may be shorter
or longer in length than is defined in the prototype." So it's up to me to
pass sane fields and a sane length, etc. I'm prepared to do that.

The question is, on options(*varsize) fields, what do I specify as the
length? The procedure knows to expect data "longer or shorter" (I suppose
they also mean equal) than whatever I specify for the length. If so, why
do I have to specify a length at all? I'm thinking about just saying the
field is 1a options(*varsize). I think that'll be like passing a pointer,
except the caller doesn't have to do %addr.

Thanks.
brian.


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.