The Museum of HP Calculators

HP Forum Archive 16

[ Return to Index | Top of Index ]

48G compiled local variable problem
Message #1 Posted by Hal on 4 Sept 2006, 8:53 a.m.

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

      
Re: 48G compiled local variable problem
Message #2 Posted by Thomas Okken on 4 Sept 2006, 10:39 a.m.,
in response to message #1 by 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' >>

and

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

HTH,

- Thomas

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

      
Re: 48G compiled local variable problem
Message #3 Posted by John Cadick on 4 Sept 2006, 2:16 p.m.,
in response to message #1 by Hal

Hello Hal:

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

{ var1 var2 var3 var4 . . . } PURGE

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.

John

            
Re: 48G compiled local variable problem
Message #4 Posted by Hal on 5 Sept 2006, 12:54 a.m.,
in response to message #3 by John Cadick

Thanks for the responses...They got me going.
regards, Hal


[ Return to Index | Top of Index ]

Go back to the main exhibit hall