HP Forums

Full Version: 48G compiled local variable problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hi Folks,

I have a simple program on my HP48G to take three numbers from the stack, put them into 3 compiled local variables, and then evaluate three algabraic objects (which are stored in 3 separate global variables). The problem is, the local variables don't seem to persist beyond the first evaluation. After that I get an undefined local name error. Here is the syntax of my program:

<< -> <-X <-Y <-Z 'M'->NUM 'A1'->NUM 'A2'->NUM >>

Where X, y, and Z are my compiled local variables, which are called for in all three global variables (M, A1, and A2). It doesn't matter what order I put the globals in...just the first one gets evaluated, then the name error. Can I not use compiled local variables like this, or do I just have a syntax error?

One more quick question if I may...how can I purge global variables programmatically?
Any help much appreciated.

Best regards, Hal

I'm surprised your program even executes -- according to the manual (page 29-16), there are only two allowed syntaxes for local variables:

   << -> name1 name2 ... namen 'algebraic' >>


   << -> name1 name2 ... namen << program >> >>

Apparently, if additional items exist after the algebraic or program, they are executed, but the local variables only apply to the first item that follows them.

To fix your program, simply wrap the

   'M' ->NUM 'A1' ->NUM 'A2' ->NUM

bit inside << and >> delimiters and you should be OK.

Regarding your question about purging programmatically: nothing could be easier; for example

   << 'A' PURGE >>

will purge the global variable A.


- Thomas

Edited: 4 Sept 2006, 10:48 a.m.

Hello Hal:

Thomas answer for purging variables in a program can be expanded if you wish to purge multiple variables.

{ var1 var2 var3 var4 . . . }

Will get the job done for one or one hundred variables.

I always end my programs this way because I really get aggravated by programs that leave the directory littered with variables.


Thanks for the responses...They got me going.

regards, Hal