A CONST parm will only generate to a new address if the passed value
needs to be cast to a different format (ie. Packed to zoned).... In
cases where your value exactly matches the prototyped parm, it simply
passes the pointer to the original field.
If the caller used a prototype to call PGMX, specifying CONST for all
input only parms, but PGMX did not use PR/PI, then the compiler would
not protect changes to those fields. In this case, the caller passed
the pointer to the original field, expecting that the called program
would protect these values from change. The called program was allowed
to change the value in that field, which maps back to storage in Caller.
Moral: Use your prototypes. CONST works on the assumption that CALLER
and CALLED are using the same prototype for validation.
Hth,
Eric DeLong
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of rob@xxxxxxxxx
Sent: Wednesday, January 28, 2009 12:33 PM
To: RPG programming on the IBM i / System i
Subject: Re: CONST and VALUE revisited
That article made no mention of how the const can be inadvertently
modified. In fact, it leads us to believe that is not a possibility.
Rob Berendt
--
Group Dekko Services, LLC
Dept 01.073
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com
From:
"sjl" <sjl_abc@xxxxxxxxxxx>
To:
rpg400-l@xxxxxxxxxxxx
Date:
01/28/2009 01:15 PM
Subject:
Re: CONST and VALUE revisited
Sent by:
rpg400-l-bounces@xxxxxxxxxxxx
David wrote:
I thought I would read in the data area in my main procedure
and then directly call a subprocedure with CONST on the parameter
to protect my data area.
However, from experience I've noticed that it is still possible to
modify
the parameter inadvertently, and we have already discussed this.
Someone said that CONST in reality only means that the parameter
is not INTENDED to be changed.
So, I just thought it was a bit ironic : normally, I use CONST on all
parameters
used for input. But now that I REALLY don't want my parameter to be
changed,
I shall code VALUE instead.
David -
I have this page bookmarked:
http://www.web400.com/download/ilerpg/subprocedure_parameters2.htm
- sjl
As an Amazon Associate we earn from qualifying purchases.