Should Global Variables Retain Their Values After Program Execution
|
01-12-2015, 04:30 AM
(This post was last modified: 01-12-2015 04:40 AM by SEzzell.)
Post: #1
|
|||
|
|||
Should Global Variables Retain Their Values After Program Execution
I was working on my first HP Prime program and can get the program to produce output with correct answers for values I am seeking, however, I desire to be able to continue using the values stored in the global variables I created when the program is run with the data I input. After running, the variables are listed as user variables for my program, but have not retained the values shown in the output statements. It appears the values are all zero. I have attached a text file with the code and would appreciate any help.
|
|||
01-12-2015, 04:34 AM
(This post was last modified: 01-12-2015 04:34 AM by Kevin Ouellet.)
Post: #2
|
|||
|
|||
RE: Should Global Variables Retain Their Values After Program Execution
Yes, IMHO they should, or there should be a clear tutorials on how to do it. Unfortunately, they don't right now.
-Dream of Omnimaga https://dreamofomnimaga.page |
|||
01-12-2015, 06:26 AM
Post: #3
|
|||
|
|||
RE: Should Global Variables Retain Their Values After Program Execution
It appears you declared a few variables as global via the export command at the top. However, you then also declared local variables of the same name, which of course have higher priority. Thus, the global variables are never actually updated. Remove the variables whose value you wish to retain from the LOCAL statement (line 8).
Graph 3D | QPI | SolveSys |
|||
01-13-2015, 03:53 AM
Post: #4
|
|||
|
|||
RE: Should Global Variables Retain Their Values After Program Execution
I made the changes you suggested, removing the local declaration from the scope of the program and used just the export keyword to make the variables global. After running some test data, I found that I could use those values stored in the global variables in later calculations. This is just the way I wanted the program to work!
This was very helpful and I appreciate your assistance Han. |
|||
01-13-2015, 03:54 AM
Post: #5
|
|||
|
|||
RE: Should Global Variables Retain Their Values After Program Execution
Glad to hear that it worked for you; keep in mind that anytime you edit your program, though, those global variables are reset.
Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)