Midrange News for the IBM i Community


Posted by: TFisher
Multiple parameters sharing the same variable
has no ratings.
Published: 05 Nov 2012
Revised: 23 Jan 2013 - 1586 days ago
Last viewed on: 28 May 2017 (2362 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Multiple parameters sharing the same variable Published by: TFisher on 05 Nov 2012 view comments(2)

I have been working on finding a bug today with another developers function and I am trying to write this up in some documentation.

 

Someone coded a function call like this:

   Callp prProcedure( MyVariable :%Len(MyVariable) :MyVariable);

Then they couldn't figure out why the function was returning blanks when MyVariable was being passed in through the first parameter with a value.  They expected a value to be returned and loaded into MyVariable through the third parameter.

 

The problem was that the function cleared the first parameter before it did any processing and therefore MyVariable was blank when it came time to process it.

 

What I am trying to remember is if there is a name for duplicating variables on a call to a program or procedure.  Does anyone recall if there is a name for sharing a variable across multiple parameters?

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Multiple parameters sharing the same variable
Posted: 4 years 6 months 23 days 4 hours 24 minutes ago

No there is not.

what you can do however is to use the VALUE keyword on your 3rd parameter.  This will force the compiler to create a temp variable and therefore appear as 2 distinct parameter values. 

Posted by: TFisher
Premium member *
Comment on: Multiple parameters sharing the same variable
Posted: 4 years 6 months 23 days 4 hours 8 minutes ago

VALUE wasn't an option since *VARSIZE was used.  I actually know how to fix it, just trying to document it and I didn't know if there was a name for sharing variables across multiple parameters. 

 

THANKS!