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



Barbara,

Thanks for the info.

Let me make sure I understand, you said "With const varying
parameters, with or without *VARSIZE: if the passed varying parameter
might have a current length that is longer than the prototyped
parameter, the compiler currently uses a temporary and always assigns
the passed parameter to the temporary."

So if I've got a procedure defined like so:
     d Proc1b          pr
     d  msgData                   32768a   const varying 

Adding OPTIONS(*VARSIZE) has no effect when passing literals and/or
string expressions, unless what I'm passing is greater than 32768.

That's what I was hoping for, but I was afraid that the temporary
variable built would end up defined as varying(32768) just like the
temporary would have been defined as char(32768) if the parm had been
defined without the varying.  To keep the temporary used when the parm
is char(32768) from being any larger than it needs to, I'd normally code
OPTIONS(*VARSIZE).  But of course, then I need to either use OPDESC or a
second parm to get the length actually passed.  


In other words, I'm used to defining
     d Proc1a          pr
     d  msgData                   32768a   const options(*VARSIZE)
     d  msgLen                       10u   const

Instead, I can use:
     d Proc1b          pr
     d  msgData                   32768a   const varying 

And my procedures will be easier to code (no OPDESC) and/or easier to
call (no second parm).  But there's really no reason to code:
     d Proc1c          pr
     d  msgData                   32768a   const varying
options(*VARSIZE) 

As OPTIONS(*VARSIZE) as no effect on a CONST VARYING.



Thanks again,

Charles Wilt
--
iSeries Systems Administrator / Developer
Mitsubishi Electric Automotive America
ph: 513-573-4343
fax: 513-398-1121
  

> -----Original Message-----
> From: rpg400-l-bounces@xxxxxxxxxxxx 
> [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Barbara Morris
> Sent: Monday, May 08, 2006 2:33 PM
> To: rpg400-l@xxxxxxxxxxxx
> Subject: Re: CONST Parameter passing, varying and *varsize
> 
> "Wilt, Charles" wrote:
> > ...
> > But, I did confirm that if you passed a varying(10) 
> variable containing
> > more than 5 characters to a procedure with a parm defined CONST
> > varying(5) options(*varsize); the procedure only sees 5 
> chars and %len
> > returns 5.
> > 
> > I was concerned that %len() would return 10 as CONST 
> OPTIONS(*VARSIZE)
> > usually mean the address of the variable is passed 
> directly; but for a
> > varying field, the first 2 bytes contain the current length.  The
> > compiler is obviousily smart enough to handle what I was trying
> > correctly, but I don't know if it is doing some sort of a 
> substr or if
> > it is moving the varying(10) data to a varying(5) temporarily.
> > 
> > I suppose it's also possible that %len() doesn't look at the current
> > length value of a varying field, or the compiler is doing 
> something when
> > it is used with a CONST VARYING OPTIONS(*VARSIZE) field.
> > 
> 
> Charles, parameter passing for CONST and VALUE parameters basically
> works like an EVAL from the passed parameter to the prototyped
> parameter.  If necessary the compiler will actually do an EVAL between
> the passed parameter and a temporary defined like the prototyped
> parameter, and then pass the temporary.  Basically, the specified
> parameter is passed only when the called procedure could not 
> detect the
> difference between the specified parameter and a temporary.  (The
> compiler assumes that the called procedure is going to access the
> parameter's value legally with respect to the options.) 
> 
> CONST OPTIONS(*VARSIZE) doesn't necessarily say that the 
> address of the
> parameter is passed directly, even if both passed and prototyped
> parameters are the same with respect to varying.  With const varying
> parameters, with or without *VARSIZE: if the passed varying parameter
> might have a current length that is longer than the prototyped
> parameter, the compiler currently uses a temporary and always assigns
> the passed parameter to the temporary.  It could, if it 
> wanted to, check
> the length, and if it was not greater, it could just pass the 
> address of
> the passed parameter.
> 
> -- 
> This is the RPG programming on the AS400 / 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.
> 
> 


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.