Post Reply 
How can I have TWO separate Global Variables with the SAME Name?
01-31-2015, 01:21 AM
Post: #1
How can I have TWO separate Global Variables with the SAME Name?
How can I have TWO separate Global Variables with the SAME Name?
I dunno, but I did it.

Looking in Shift Mem/User Variables I see TWO with the exact same Name.

"SF" which is used in my programs. It's a REAL type
It's Declared at the top of the Source Project File.

What's more I can change the value on one of them and it does not affect the other!

The other problem is how do you get rid of them?
(or ANY variable for that matter, there is no Delete button)
"purge(SF)" doesn't work. (says no such Variable)

Tried to Clone Calc to Emulator for a screen shot but the double instance of the variable didn't come over.
So took the attached pic with my iPhone.


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
01-31-2015, 01:37 AM
Post: #2
RE: How can I have TWO separate Global Variables with the SAME Name?
(01-31-2015 01:21 AM)bobkrohn Wrote:  How can I have TWO separate Global Variables with the SAME Name?
I dunno, but I did it.

Looking in Shift Mem/User Variables I see TWO with the exact same Name.

"SF" which is used in my programs. It's a REAL type
It's Declared at the top of the Source Project File.

What's more I can change the value on one of them and it does not affect the other!

The other problem is how do you get rid of them?
(or ANY variable for that matter, there is no Delete button)
"purge(SF)" doesn't work. (says no such Variable)

Tried to Clone Calc to Emulator for a screen shot but the double instance of the variable didn't come over.
So took the attached pic with my iPhone.

purge() deletes CAS variables only; if you have multiple programs that each export SF as a variable, that is one way to have several instances. It even happens with programs. Usually the most recently created program/variable has the higher priority. It may also be due to apps having the same exported variable, so that App.SF is different from just plain-old SF. The priority here is based on what the current app is.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
01-31-2015, 05:17 AM
Post: #3
RE: How can I have TWO separate Global Variables with the SAME Name?
(01-31-2015 01:21 AM)bobkrohn Wrote:  The other problem is how do you get rid of them?
(or ANY variable for that matter, there is no Delete button)

Although there is no Delete button, there is a Delete key. To purge any variable that you created in Home (not in a program, or in a user-defined function, or in CAS), highlight it in either the Vars / User / User Variables menu, or in the Memory Manager / User Variables list, then press either the backspace key, or the Del key (Shift backspace). It will immediately be purged without asking "Are you sure?" nor giving any notice of its deletion, so be careful. Unlike HP's RPL models, Prime offers no undo option after accidental purging of a variable.

In the Memory Manager, in addition to backspace and Del, the Clear key (Shift Esc) also purges the highlighted variable. This is strange, since Clear doesn't do anything in the Vars / User / User Variables menu.

To purge ALL the variables that you created in Home, highlight "User Variables" in the Memory Manager, and press either backspace or Del (Shift backspace). Do NOT press Clear there, unless you wish to clear ALL of memory (don't worry; it asks for verification first).

All of the above is only about variables created in Home, because I assume that's what you're referring to, e.g. ABC:=123. Variables created in programs, user-defined functions, and in CAS, are purged differently.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
01-31-2015, 06:04 AM
Post: #4
RE: How can I have TWO separate Global Variables with the SAME Name?
OK, here's my learning experience.
Del, Shift Del and Shift Esc didn't do anything.

I didn't realize that Exporting a Variable in a program that has been compiled created a permanent variable.
The way to "delete" the variable is to simply remove the Export instruction from the program.
I had two related programs that did the Export command for "SF".
However, I assumed that they would be referring to the same variable.
i.e. could access the value held there. OOPS!
There is no way to know which variable was which.

I have a better understanding now. Thanks
Find all posts by this user
Quote this message in a reply
02-02-2015, 06:41 AM
Post: #5
RE: How can I have TWO separate Global Variables with the SAME Name?
Hello

(01-31-2015 06:04 AM)bobkrohn Wrote:  I didn't realize that Exporting a Variable in a program that has been compiled created a permanent variable.
I had two related programs that did the Export command for "SF".
However, I assumed that they would be referring to the same variable.

I am glad that yo solved your issue.
EXPORT specifies that a global variable of your program is visible/useable from outside your program. It is still that specific program variable. Therefore, yes, it is possible to create 2 variables with the same name.

Know, that you can always refer to a SPECIFIC variable by doing program_name.varaible:= value... this is called fully qualifying a variable.

Of course, the alternative would have been, as you were originally expecting, to have the 2 variables merged, BUT this would most likely have lead to issue with 2 unrelated programs contaminating eachothers's variables.

cyrille
Find all posts by this user
Quote this message in a reply
02-02-2015, 10:56 PM
Post: #6
RE: How can I have TWO separate Global Variables with the SAME Name?
Yup, the way the Prime is setup is not "wrong" or a "bug".
It's just a subtle difference from what I "expected".

OK, so a request to make for a future firmware upgrade.

Put something in the User Variable Viewer to notify the User which App or User Program the Custom Variable is connected to. Looks to be plenty of room on the screen.

Thanks
Find all posts by this user
Quote this message in a reply
02-03-2015, 10:24 AM
Post: #7
RE: How can I have TWO separate Global Variables with the SAME Name?
Yup, the way the Prime is setup is not "wrong" or a "bug".
It's just a subtle difference from what I "expected".

OK, so a request to make for a future firmware upgrade.

Put something in the User Variable Viewer to notify the User which App or User Program the Custom Variable is connected to. Looks to be plenty of room on the screen.

Thanks
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)