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



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>
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.
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
VARYING and CONST parameters are cool and useful.
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. 

Note that if the parameter is just CONST, and is character, it is always padded
to the length of the parameter definition, with blanks.


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

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

I did some testing...

Unfortunately, it seems my simple test programs all ended up with the
same program size and static storage size. So I still don't know what's
going on.

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.

I'm hoping Barbara or another IBM'er will chime in on this thread.



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 Bob Cozzi
> Sent: Friday, May 05, 2006 4:59 PM
> To: 'RPG programming on the AS400 / iSeries'
> Subject: RE: CONST Parameter passing, varying and *varsize
> 
> Temp variables are declared in the program/module at 
> compile-time. They aren't
> dynamically created at run time.
> 
> I think I had that CONST OPTIONS(*VARSIZE) thing wrong.
> But it is confusion.
> %SUBST-like functionality is used sometimes. Sometimes the 
> data is copied to a
> temp variable.
> I'll have to dig in my email to figure out what the specifics are.
> 
> In the case of different size VARYING parameter values, remember, in a
> subprocedure, you can change the content of a CONST 
> parameter, this includes
> restricting use of %LEN() to change the current length. 
> -Bob Cozzi
> www.RPGxTools.com
> RPG xTools - Enjoy programming again.
> 
> 


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.