|
And remember, If %addr(constParm) = *NULL Only works in V5R1 and later. To get it to be *NULL, you have to pass in *OMIT (which is an entirely different thread. <g>) -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 Scott Klement Sent: Saturday, September 03, 2005 2:46 PM To: RPG programming on the AS400 / iSeries Subject: Re: Constants (was: *varsize array as procedure parameter) > If a const is just a pointer to a variable that isn't allowed to be > changed ... is there any reason I couldn't take the address of that > pointer, assign it to another (non-const) variable, and change the > const's value that way? The compiler won't let you take the address of a CONST variable and assign it to something. (You can use it in a comparison, such as to check if it's *NULL, but when the parm is CONST, it won't let you store the output of %addr() into a variable.) // this code is legal: if %addr(ConstParm) = *NULL; // this code is not: ptr = %addr(ConstParm); It is possible to TRICK the compiler, such as when you use a prototype that doesn't match the procedure interface, or when you go outside the scope of the subprocedure to get the address from the caller. In those cases it is, in fact, possible to change the value of a CONST parameter. But, that's going pretty far out of your way when you could've just left the "CONST" off of the prototype in the first place.
As an Amazon Associate we earn from qualifying purchases.
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.