Global vs Local behaviour
|
05-03-2015, 08:33 PM
Post: #6
|
|||
|
|||
RE: Global vs Local behaviour
For my own piece of mind I wanted to verify how global user variables are passed into a program on the Prime, here is what I did, and what I found:
Here is the test program; please note that the input variable name (stx) is different from the global user variable name passed in (stg) on the command line below. Code:
The following is what I entered on the command line: Code:
I then changed the program to modify the value of the global user variable: Code:
And entered the following on the command line: Code:
As you can see the original value of the global user variable stg (10) is passed into the program via the input variable stx in the program. The value of the global user variable stg is then modified by the program and returned with the new value by the RETURN statement. Summary: Input variables are passed by value and not by reference. You must use a different name in your program for the local input parameter variable than that of your global user variable used for RETURN. You can pass in the same global user variable as that declared in your program, and then modify and return the new value in the same global user variable name. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Global vs Local behaviour - DrD - 05-02-2015, 03:24 PM
RE: Global vs Local behaviour - kharpster - 05-02-2015, 08:38 PM
RE: Global vs Local behaviour - DrD - 05-02-2015, 09:56 PM
RE: Global vs Local behaviour - kharpster - 05-02-2015, 10:29 PM
RE: Global vs Local behaviour - DrD - 05-03-2015, 02:18 AM
RE: Global vs Local behaviour - kharpster - 05-03-2015 08:33 PM
RE: Global vs Local behaviour - cyrille de brébisson - 05-04-2015, 04:41 AM
RE: Global vs Local behaviour - DrD - 05-04-2015, 11:34 AM
RE: Global vs Local behaviour - Didier Lachieze - 05-04-2015, 01:32 PM
RE: Global vs Local behaviour - DrD - 05-04-2015, 01:47 PM
RE: Global vs Local behaviour - leprechaun - 05-04-2015, 05:47 PM
|
User(s) browsing this thread: 4 Guest(s)