Post Reply 
Question about user vars
04-06-2015, 11:28 AM (This post was last modified: 04-07-2015 05:46 AM by Dirk.nl.)
Post: #1
Question about user vars
I'm new on this forum. My name is Dirk Hartland living in a village south of Rotterdam in the Netherlands. Retired, 41 years worked for a electrical company (van Rietschoten & Houwens) as consultant for offshore control systems for crane and pipe-lay barges (Hereema, Allseas, etc.)


Questions about HP Prime's user variables.
I'm new, sorry, maybe already asked.
Software version 6975

First item:
I have made two very simple test programs (TEST1 and TEST2) to test the behavior of the exported user var's. TEST1 export var = AA1 with the value of 12 and TEST2, the same var AA1 with the value of 24.
First I programmed TEST1 and second TEST2.
First running TEST1 and second TEST2.

Results.
vars-user-TEST1-AA1 = 24 (I expected a value of 12)
vars-user-TEST2-AA2 = 24
command line; AA1 = 24
command line; TEST1.AA1 = 12 (correct!)
command line; TEST2.AA2 = 24

I have tried running first TEST2 en secondly TEST1, no difference.

Question:
How must I interpret the results of the user vars and what is the difference between selecting AA1 from function "vars-user-TEST1-AA1" and from command line, "TEST1.AA1"?
In both cases I select TEST1.

Second item:
In a solve app I used a variable Ul (U line)
I changed both TEST programs. Both programs, export vars are Ul.

First running the app, Ul = 440.
vars-user-user variables-Ul = 440
vars-user-TEST1-Ul = 440
vars-user-TEST2-Ul = 440

Running TEST1 and TEST2
solver app Ul = 24
vars-user-user variables-Ul = 24
vars-user-TEST1-Ul = 24
vars-user-TEST2-Ul = 24
command line, TEST1.AA1 = 12 (correct!)
command line, TEST2.AA2 = 24

Deleting TEST1 and TEST2
solver app Ul = 440 (automatically back to 440!)
vars-user-user variables-Ul = 440

Question:
User var behavior is about the same as the first item.
Ul in solver app automatically goes back to 440. Was the value of solver app's Ul saved elsewhere?
How are user vars presented and organized inside function VARS? (Inside Prime's memory?)

Sorry for my bad English.
Greetings, Dirk.nl
Find all posts by this user
Quote this message in a reply
04-07-2015, 09:12 PM
Post: #2
RE: Question about user vars
Hello,
I have read some threads from Han about user vars. That gave me more understanding, thanks Han.

Local vars, declared between "begin" and "end" are only available for that part of code.
Vars declared on the first program line (like; "var:=value") are global vars for hole the program and can also be used by other programs as "prog name"."var name". Those vars are not visible under key "vars" -> "user". (Can also be used in the home - command line.)
Vars declared as exported on the first program line are also global vars and also available for other programs, but will also be presented (and selectable) under key "vars" -> "user" -> "prog name".
In other words; the exported var can only be selected after selection of the corresponding prog name. This implicates (especially when you are using the same "var name" in other programs) that when you select the global var of a program the outcome in the command line, I think, must be "prog name"."var name".
It's not really a problem when you know how it works, don't use the same "var name" for exported vars!
I think the presentation of the (exported) user vars are not logical enough.

Greetings, Dirk.nl
Find all posts by this user
Quote this message in a reply
04-09-2015, 01:15 AM
Post: #3
RE: Question about user vars
Correct -- when exporting variables, the unqualified names are based on the most recent reference (e.g. whichever was "compiled" most recently; also using Run from the program catalogue seems to have similar effects). So if you have two programs: TEST1 and TEST2 and both programs export a variable called MYVAR, then to avoid any ambiguity, it is best to qualify them via TEST1.MYVAR or TEST2.MYVAR. The only case where you can be sure which MYVAR is used is within the source file for TEST1 (which would use the MYVAR associated with TEST1) or within the source file for TEST2 (which would use the MYVAR associated with TEST2).

The same idea holds for Apps, too.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
04-09-2015, 05:33 AM
Post: #4
RE: Question about user vars
Okay Han, tanks again!

Greetings, Dirk.nl
Find all posts by this user
Quote this message in a reply
Post Reply 




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