HP50g Global variables scope



#3

I'm a new user of HP50g, so maybe a basic question. I want to have some trivial programs in Home directory, some of these programs need to use values stored in global variables. It's easy to do with the variables stored in Home, but then Home directory has too many entries and it's quite confusing. I would like to have a subdirectory, e.g. "MYVARS" to store the global variables. How can I access these variables from a program running in Home directory? I could do it the opposite way (to have variables in Home and run the programs in a subdirectory, then the variables are accessible - but I'd prefer the first setup).
In general, is it possible in UserRPL to address a global variable really globally, something like fully qualified file names (including path) on a PC?
Thanks


#4

How about a structure like this:
Home
DIRs ... CASDIR
EXAMs ....Projs
EXAM.1
PROG ... VAR1 VAR2 VAR3 VAR4
|
Prg1 Prg2

Say, Prg1 uses VAR1 and VAR4, Prg2 uses also VAR1 plus VAR3
The variables are up in the PATH so they a used directly
when their names are not quoted eg. VAR1 instead of 'VAR1'
When you STOre into a variable "one floor up"
you can use something like this:
<< PUSH UPDIR 15 'VAR1' STO POP >>

where PUSH poushes you flags and current PATH to a variable
ENVSTACK in CASDIR, where they are POPped ...OR
<< PATH -> p << UPDIR 15 'VAR1' STO p EVAL >> >>

actually you could leave the PATH result in the stack
and do some manipulations to get it out of the way
and to bring it back to the top of stack for EVAL

Alternatively you could have the directories reversed:
Home
DIRs ... CASDIR
EXAMs ... Projs
EXAM.1
VARs ... Prg1 Prg2
|
VAR1 VAR2 VAR3 VAR4

Now recalling goes like this:
<< { VARs VAR1 } RCL >>

STOring:
<< VARs 15 'VAR1' STO UPDIR >>

You could have other variations
like using variables from below, same level and UPDIR
anyway anything higher on your PATH
will get executed by a simple reference with no quotas
whether the name refers to a program or a variable
Variable 'execution' will just recall the contents
that is, if the 'name' contains a value
string, complex number, matrix, algebraic, list, library
BUT
if the contents are: a program, CODE, etc, it will be run
it's just like using the command line and pressing [ENTER]

more..?


#5

Thanks for the hints, I'll experiment a bit to see which method suits me most.


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP: Dump the predefined variables! bluesun08 12 3,956 11-19-2013, 02:18 PM
Last Post: bluesun08
  Prime: Scope of Variable and functions within programs Thomas Chrapkiewicz 9 3,443 11-18-2013, 03:39 PM
Last Post: Thomas Chrapkiewicz
  HP Prime - local variables retain their initial type BruceH 4 1,960 11-10-2013, 12:42 PM
Last Post: Michael de Estrada
  Shutdown with the Apps key and more than 10 variables in a program. Davi Ribeiro de Oliveira 10 3,996 11-05-2013, 01:26 PM
Last Post: Han
  HP Prime: Number of external Variables Davi Ribeiro de Oliveira 0 1,059 11-01-2013, 08:10 PM
Last Post: Davi Ribeiro de Oliveira
  HP Prime variables Davi Ribeiro de Oliveira 3 1,756 10-31-2013, 02:24 AM
Last Post: cyrille de Brébisson
  HP Prime - deleting variables bluesun08 1 1,281 10-29-2013, 06:36 PM
Last Post: Joe Horn
  HP Prime: CAS Variables - -How to save? Helge Gabert 2 1,906 10-27-2013, 11:26 PM
Last Post: Helge Gabert
  HP Prime Solver Variables Issue Anibal Morones Ruelas 8 3,193 10-19-2013, 09:45 AM
Last Post: Harold A Climer
  Prime RPN storing variables kris223 3 1,790 09-19-2013, 03:49 PM
Last Post: kris223

Forum Jump: