Post Reply 
Unexxpected Procedure Call (Solved) when variable undefine
11-24-2016, 10:31 PM (This post was last modified: 11-25-2016 04:56 PM by StephenG1CMZ.)
Post: #4
RE: Unexpected Escape when variable undefined (SOLVED...My mistake)
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.
Code:


 //KK
 EXPORT KK()
 BEGIN
  LOCAL KK;
  //MSGBOX(STRING(K_Esc));
  WHILE 1 DO
   KK:=GETKEY();
   IF KK≠−1 THEN
    PRINT(KK);
    IF KK==4 THEN
     MSGBOX("ESCAPE");
    END;
   END; 
  END;
 
 END;

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


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



User(s) browsing this thread: 1 Guest(s)