The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

HP50g Global variables scope
Message #1 Posted by vq on 22 Oct 2008, 6:43 a.m.

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

      
Re: HP50g Global variables scope
Message #2 Posted by V-PN on 22 Oct 2008, 8:24 a.m.,
in response to message #1 by vq

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..?

            
Re: HP50g Global variables scope
Message #3 Posted by vq on 22 Oct 2008, 9:27 a.m.,
in response to message #2 by V-PN

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


[ Return to Index | Top of Index ]

Go back to the main exhibit hall