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



Not sure how you would "pass back" a value to a CONST VARYING parameter.
Changing _any_ CONST parameter value is not allowed anyway.

-Bob Cozzi
www.RPGxTools.com
RPG xTools - Enjoy programming again.


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On
Behalf Of Wilt, Charles
Sent: Monday, May 08, 2006 12:57 PM
To: RPG programming on the AS400 / iSeries
Subject: RE: CONST Parameter passing, varying and *varsize

> -----Original Message-----
> From: rpg400-l-bounces@xxxxxxxxxxxx 
> [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Bob Cozzi
> Sent: Monday, May 08, 2006 11:29 AM
> To: 'RPG programming on the AS400 / iSeries'
> Subject: RE: CONST Parameter passing, varying and *varsize
> 
> Charles,
> I think you're trying to prove to yourself that it doesn't 
> work they way it
> works, but the way you believe it could/should work. 
> Let it go...  <vbg>

Really I'm not.  I'm quite happy with the way it works.  I'm simply
intrigued by the workings of VARYING, CONST, and OPTIONS(*VARSIZE).
More specifically, how they work with each other.


> OPTIONS(*VARSIZE) is intended to be used when a variable is 
> passed by reference
> and you either use OPDESC or pass a second parameter with the 
> length of the
> first parameter. 
> Certainly it may be used with CONST, to override the fact 
> that if the length of
> the value being passed is also passed in a second parm, you 
> can extract the
> data.
> 
> Using OPTIONS(*VARSIZE) with VARYING is purely to allow you 
> to cast/map between
> different data types. You also get the flexibility to check 
> the input length
> without the second parameter. But as when you include a 
> length parameter, you
> don't touch data outside the scope of the variable being passed.

Seems to be true IIF the parm is declared to be bigger than the variable
being passed.  If you pass a varying(10) as a parameter defined
varying(5), you get a RNX0115 - Length of varying length variable is out
of range; at run time whenever you refer to the parm, even if only
trying to the current %len, but no error during compile.

In addition, unless you have CONST on the parameter, you still need that
second parameter (or OPDESC?) to determine the max size string you can
pass back.  If you've got a varying(10) passed through a varying(15)
paramter def, %len(parm) gives you only the current size, not the 10
that can be returned.  %size(parm) gives you 17 (15 + 2).  The compiler
will let you assign 11+ charactors to the parm, but you get the RNX0115
during runtime. 


> CONST VARYING and OPTIONS(*VARSIZE) allows you to do more, 
> but you still have to
> live within the restrictions. 
> VARYING has nothing to do with CONST
> OPTIONS(*VARSIZE) has nothing to with VARYING

Yes, I understand CONST and OPTIONS(*VARSIZE) effect how a parameter is
passed, whereas VARYING is really a different data type altogether.  I
believe Scott (and you ?) have often said that VARYING never should have
been a keyword, and instead it should have been a separate data type.
I'd agree to agree with that thought, hearing it way back when cleared
up my confusion between OPTIONS(*VARSIZE) and VARYING.

But while I'm confortable with my knowledge of what effects CONST and
OPTIONS(*VARSIZE) have on fixed length data types, I'm questioning the
effects of CONST and OPTIONS(*VARSIZE) on the VARYING data type.  More
imporatantly, the differences OPTIONS(*VARSIZE) has on fixed length data
types vs. the VARYING data type.

> VARYING and CONST parameters are cool and useful.

Yep.

> CONST or non-CONST and *VARSIZE with a length or OPDESC are 
> cool and useful.
> CONST or VARYING without *VARSIZE is useful.
> 
> VARYING CONST OPTIONS(*VARSIZE) is rare and should be used 
> when you know the
> length of the data you're passing it. 
> 

All I'm trying to do is decide the easiest method of passing in a
variable length string literal or string expression.

With CONST OPTIONS(*VARSIZE), I have to include a second parm with the
length.

With CONST VARYING, I don't need that second parm. But I was expecting
to need CONST VARYING OPTIONS(*VARSIZE).

However, it doesn't appear that CONST VARYING OPTIONS(*VARSIZE) offers
anything over the behavorior of just CONST VARYING.

Thanks,
Charles Wilt



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.