HP Forums
Unexxpected Procedure Call (Solved) when variable undefine - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Unexxpected Procedure Call (Solved) when variable undefine (/thread-7241.html)

Unexxpected Procedure Call (Solved) when variable undefine - StephenG1CMZ - 11-15-2016 10:43 PM

In this program, when I forget to define variable KK (it was defined until I split the procedure into two procedures, one omitted here), Running the program seems to execute a WAIT, and when I tap ESC an "ESCAPE" MSGBOX appears.
The KIF MSGBOX only appears if the variable is defined.


 EXPORT Precision10 (JJ)
  //LOCAL KK:=LOG(2);



RE: Unexpected Escape when variable undefined - cyrille de brébisson - 11-16-2016 06:15 AM


I defined KK in home.
Then I entered your program.
Then I deleted KK from home.
then I ran the program.

I got the expected "Error: Unmatched control word" error.

Is that not what you are seeing?


RE: Unexpected Escape when variable undefined - StephenG1CMZ - 11-16-2016 08:53 AM

Here is what I see when I run the program and tap ESC.

I did write some code a few months ago that waited for a keypress and MSGBOXed ESCAPE, whilst debugging some other program. But if I tap something other than ESC I get the system "!", whereas my old code would have ignored other keypress or printed the ASCII code.

The code here originally measured the available precision in bits, then multiplied by log(2) to show decimal digits of precision. That worked, but I decided to separate the bit-measuring into a separate procedure and accidentally had the LOCAL KK in the wrong procedure - and the program began waiting for an ESC. Defining KK in the correct procedure fixed that.

It might be relevant that for some time now, my Android phone has been warning that it is running out of storage space.

RE: Unexpected Escape when variable undefined (SOLVED...My mistake) - StephenG1CMZ - 11-24-2016 10:31 PM

Oh, how silly of me.
I wasn't expecting that ESCAPE to print, and Android had been telling me things might not work correctly as I am running out of storage space.
In my defence, I have seen other platforms sometimes jumble up file contents into the wrong files.

I remembered writing a couple of lines of code to print ESCAPE, as part of some other program, but remembered it as just a couple of lines of in-line code whilst testing key handling - so didn't think it should execute.

Enough excuses.

The code had actually been written as an exported procedure, named KK!
So when variable KK was not defined...procedure KK executed.

I've no idea why I wrote that as a procedure - but when you start a procedure using the templates, the only option is to make an export function. There is no template for local functions. If I had made it local, it wouldn't have been seen. Template/Function/Export only.

But the main way to avoid such confusion between variables and procedure calls, would be to require a pair of () after the KK to see it as a procedure call.

   IF KK≠−1 THEN
    IF KK==4 THEN