48G compiled local variable problem



#5

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


#6

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.

#7

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


#8

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

regards, Hal


Possibly Related Threads...
Thread Author Replies Views Last Post
  hp-prime solver and variable name fabrice48 22 1,950 12-10-2013, 03:25 AM
Last Post: fabrice48
  Prime: Scope of Variable and functions within programs Thomas Chrapkiewicz 9 786 11-18-2013, 03:39 PM
Last Post: Thomas Chrapkiewicz
  HP Prime - local variables retain their initial type BruceH 4 504 11-10-2013, 12:42 PM
Last Post: Michael de Estrada
  HP Prime - Variable problem bluesun08 12 966 11-07-2013, 11:34 AM
Last Post: bluesun08
  HP Prime Programming Tutorial #1: LOCAL, RETURN Eddie W. Shore 6 691 10-26-2013, 08:42 PM
Last Post: Miguel Toro
  HP Prime Programming: LOCAL Alberto Candel 3 371 10-07-2013, 01:31 AM
Last Post: cyrille de Brébisson
  WP-34S Matrix operations with routine-local registers? Tom Grydeland 1 318 09-04-2013, 10:46 AM
Last Post: Marcus von Cube, Germany
  WP-34S: Subroutines, local registers and hotkeys Marcel Samek 7 608 08-23-2013, 12:08 PM
Last Post: David Hayden
  WP-34S: question - Initialization of local registers Marcel Samek 8 584 07-07-2013, 09:57 PM
Last Post: Steve Simpkin
  local variables brooky 9 696 09-25-2012, 12:25 AM
Last Post: David Hayden

Forum Jump: