48G compiled local variable problem



#2

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


#3

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.

#4

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


#5

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 8,482 12-10-2013, 03:25 AM
Last Post: fabrice48
  Prime: Scope of Variable and functions within programs Thomas Chrapkiewicz 9 3,400 11-18-2013, 03:39 PM
Last Post: Thomas Chrapkiewicz
  HP Prime - local variables retain their initial type BruceH 4 1,919 11-10-2013, 12:42 PM
Last Post: Michael de Estrada
  HP Prime - Variable problem bluesun08 12 3,618 11-07-2013, 11:34 AM
Last Post: bluesun08
  HP Prime Programming Tutorial #1: LOCAL, RETURN Eddie W. Shore 6 3,075 10-26-2013, 08:42 PM
Last Post: Miguel Toro
  HP Prime Programming: LOCAL Alberto Candel 3 1,583 10-07-2013, 01:31 AM
Last Post: cyrille de Brébisson
  WP-34S Matrix operations with routine-local registers? Tom Grydeland 1 1,215 09-04-2013, 10:46 AM
Last Post: Marcus von Cube, Germany
  WP-34S: Subroutines, local registers and hotkeys Marcel Samek 7 2,474 08-23-2013, 12:08 PM
Last Post: David Hayden
  WP-34S: question - Initialization of local registers Marcel Samek 8 2,629 07-07-2013, 09:57 PM
Last Post: Steve Simpkin
  local variables brooky 9 2,698 09-25-2012, 12:25 AM
Last Post: David Hayden

Forum Jump: