HP 48GX STO Error: Undefined Local Name - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: HP 48GX STO Error: Undefined Local Name (/thread-17095.html) |
HP 48GX STO Error: Undefined Local Name - MNH - 06-12-2021 01:02 AM I'm not comprehending what's going on with STO Error: Undefined Local Name. Pressing the menu key labeled 'R' causes the message to be displayed. \<< 0 → radius \<< CLLCD " AREA OF A CIRCLE" 3 DISP 3 FREEZE { { "R" \<< 'radius' STO \>> } } TMENU \>> \>> I've defined the local name. Is the location where I call it "out of scope?" I know the program is incomplete; I stopped writing it when I encountered the error. RE: HP 48GX STO Error: Undefined Local Name - Joe Horn - 06-12-2021 02:37 AM Your program assigns << 'radius' STO >> to the F1 key (and labels it R). The variable 'radius' in that program, due to the way it was created, is a local variable. But when your program ends, that local variable is automatically purged. But pressing the F1 key ("R") attempts to store into that local variable which no longer exists. One way around this is to avoid exiting the program via a HALT command, and resuming it via the CONT key (left-shift ON). That's ugly though. In any case, 'radius' fails because you're using it outside of its defining procedure (namely, the original program which is no longer running when you press your softkey). RE: HP 48GX STO Error: Undefined Local Name - Giuseppe Donnini - 06-12-2021 09:39 AM (06-12-2021 02:37 AM)Joe Horn Wrote: One way around this is to avoid exiting the program via a HALT command, and resuming it via the CONT key (left-shift ON). That's ugly though. I beg to disagree. This is actually quite an elegant solution, if you recall that CONT is a programmable command and that you can include it as part of a menu key definition. Even Bill Wickes recommends its use in the present context. Also, instead of DISP, FREEZE, and HALT, I would use PROMPT, because it has the advantage of leaving the displayed message visible during command line entry. Otherwise, the message will vanish at the next keystroke. You could, for example, write something like this: Code: \<< 0 \-> radius For further discussion and ideas, I strongly recommend reading chapter 12.6 entitled “Obtaining Input” from Bill Wickes’ HP 48 Insights - I. Principles and Programming (starting on page 361 in the GX edition of the book, and on page 329 in the SX edition, a free copy of which is available on Eric Rechlin’s new webpage dedicated to HP literature. RE: HP 48GX STO Error: Undefined Local Name - MNH - 06-12-2021 11:32 AM (06-12-2021 02:37 AM)Joe Horn Wrote: In any case, 'radius' fails because you're using it outside of its defining procedure (namely, the original program which is no longer running when you press your softkey). This was just a test program. Page 1 of the program that I want to write has 6 input choices. I would like to use local variables to store values. I've used local variables before, but never with a menu. Thanks for replying! RE: HP 48GX STO Error: Undefined Local Name - MNH - 06-12-2021 11:39 AM (06-12-2021 09:39 AM)Giuseppe Donnini Wrote: For further discussion and ideas, I strongly recommend reading chapter 12.6 entitled “Obtaining Input” from Bill Wickes’ HP 48 Insights - I. Principles and Programming (starting on page 361 in the GX edition of the book, and on page 329 in the SX edition, a free copy of which is available on Eric Rechlin’s new webpage dedicated to HP literature. I will give your program a test run. Thanks for recommending Bill's book! |