Post Reply 
Invalid Input during local variable declaring
12-18-2013, 11:33 PM
Post: #1
Invalid Input during local variable declaring
I wonder if this is a bug or something I am doing wrong, but here's my code:

Code:
initialize();
fadeIn();
fadeOut();
titleScreen();
forVar1, forVar2, forVar3, aniCounter, ballAniFrm;

EXPORT ssballsprites()
BEGIN

initialize();
fadeOut();
titleScreen();
// end of program (for now)
END;


titleScreen()
BEGIN
   LOCAL colHeight := 0, heightChg := 0, heightChgDir := .03, bgOffset := 0,  enterPressed := 0;  //Error: Invalid input happens here

   // Generate title background
   FOR forVar2 FROM 0 TO 240 STEP 16 DO
   FOR forVar1 FROM 0 TO 320 STEP 16 DO
   BLIT_P(G5,forVar1,forVar2,forVar1+16,forVar2+16,G2,0,160,16,176);
   END;
   END;

   // Main title loop
   WHILE enterPressed=0 DO
      BLIT_P(G3,0,0,320,240,G5,bgOffset,bgOffset,320+bgOffset,240+bgOffset);
      FOR forVar1 FROM 0 TO 62.75 STEP .25 DO
         heightChg := heightChg+heightChgDir;
         IF heightChg>.5 OR heightChg<-.5 THEN
            heightChgDir := -heightChgDir;
         END;
         heightChg := heightChg+heightChg;
         BLIT_P(G3,32+(forVar1*4),30-heightChg,34+(forVar1*4),114+heightChg,G1,forVar1,0,forVar1+1,15,RGB(128,0,128))​;
      END;
      bgOffset := bgOffset+1;
      IF bgOffset=16 THEN
         bgOffset := 0;
      END;
      FOR forVar1 FROM 0 TO 14 DO
         FOR forVar2 FROM 0 TO 1 DO
            BLIT_P(G3,304*forVar2,16*forVar1,304*forVar2+16,16*forVar1+16,G2,0,16*ballAniFrm​+448,16,16*ballAniFrm+464,RGB(128,0,128));
         END;
      END;
      FOR forVar1 FROM 0 TO 3 DO
         FOR forVar2 FROM 0 TO 3 DO
            IF (forVar2=0 OR forVar2=2) AND forVar1<2 THEN
               BLIT_P(G3,64*forVar2+32,110*forVar1+5,64*forVar2+158,110*forVar1+20,G1,RGB(​128,0,128));
            END;
            TEXTOUT_P("©2014 DJ Omnimaga - www.omnimaga.org",G3,17+forVar2,215+forVar1,3,#000039);
            IF ballAniFrm=1 THEN
               TEXTOUT_P("Press Enter",G3,107+forVar2,151+forVar1,6,#000039);
            END;
         END;
      END;
      TEXTOUT_P("©2014 DJ Omnimaga - www.omnimaga.org",G3,18,216,3,#FFFFFF);
      IF ballAniFrm=1 THEN
         TEXTOUT_P("Press Enter",G3,108,152,6,#FFFFFF);
      END;
      IF aniCounter=0 THEN
         aniCounter := 1;
         fadeIn();
      ELSE
         BLIT_P(G0,G3);
         aniCounter := aniCounter+1;
         IF aniCounter=3 THEN
            aniCounter := 1;
            ballAniFrm := NOT(ballAniFrm);
            IF ISKEYDOWN(30) THEN
               enterPressed := 1;
               fadeOut();
            END;
         END;
      END;
   END;
END;

fadeIn()
BEGIN
   BLIT_P(G4,G3);
   FOR forVar1 FROM 16 DOWNTO 2 DO
      BLIT_P(G3,0,0,320/forVar1,240/forVar1,G4,0,0,320,240);
      FILLPOLY_P(G3,{{0,0},{320,0},{320,240},{0,240}}, #000000, (16*forVar1)-16);
      BLIT_P(G0,0,0,320,240,G3,0,0,320/forVar1,240/forVar1);
   END;
END;

fadeOut()
BEGIN
   BLIT_P(G4,G0);
   FOR forVar1 FROM 2 TO 16 DO
      BLIT_P(G3,0,0,320/forVar1,240/forVar1,G4,0,0,320,240);
      FILLPOLY_P(G3,{{0,0},{320,0},{320,240},{0,240}}, #000000, 16*forVar1);
      BLIT_P(G0,0,0,320,240,G3,0,0,320/forVar1,240/forVar1);
   END;
END;

initialize()
BEGIN
   // Temporary screen and background storages
   DIMGROB_P(G3,320,240);
   DIMGROB_P(G4,320,240);
   DIMGROB_P(G5,336,256);

   // Sprite data
   DIMGROB_P(G2,16,560,RGB(128,0,128,128));
   // <sprite data here, but I removed it since it won't fit in one post>

   // Title screen logo data (removed so this fits in a post)
   DIMGROB_P(G1,63,15,RGB(0,128,0));
END;

Basically, on the "LOCAL" line, I get an Invalid Input error. I checked some other people's source code for the right syntax and I seem to have the right one, so I am unsure what's wrong. Am I triggering some firmware bug or am I doing something wrong? ???

Any help would be appreciated, else I'll have to stick to global variables and in the worst case scenario, switch back to A-Z vars as I was using before (which makes the code more confusing and isn't good practice).

-Dream of Omnimaga
https://dreamofomnimaga.page
Visit this user's website Find all posts by this user
Quote this message in a reply
12-18-2013, 11:49 PM
Post: #2
RE: Invalid Input during local variable declaring
You can only have a maximum of 8 variable declarations or 4 variables with value assignments in a single LOCAL statement. So just make a second LOCAL statement for the fifth variable.
Find all posts by this user
Quote this message in a reply
12-18-2013, 11:55 PM (This post was last modified: 12-19-2013 01:00 AM by Kevin Ouellet.)
Post: #3
RE: Invalid Input during local variable declaring
It still doesn't work even with a second LOCAL statement :/

LOCAL colHeight := 0, heightChg := 0, heightChgDir := .03, bgOffset := 0;
LOCAL enterPressed := 0;

Now the error only happens during runtime, though, not debugging. During debugging, it now just randomly "This application has crashed and will be restarted" or give Runtime errors then exits.

Even if I set those variables as global vars at the start of the program I still get the Invalid input error.

EDIT: Nevermind, I might have accidentally swapped two variables when switching from the A to Z ones. My bad. Thanks.


Btw: Seriously, to those who plan to get an HP Prime reading this post: The emulator doesn't do it justice. It's so buggy compared to the real thing. The real calc crashes much less often and since the firmware update it's even better. The emulator is just brutal in terms of stability and when it starts crashing, it becomes no longer functional (actually, if the connectivity kit is open, the emulator even becomes sentient sometimes).

-Dream of Omnimaga
https://dreamofomnimaga.page
Visit this user's website Find all posts by this user
Quote this message in a reply
12-19-2013, 12:59 AM (This post was last modified: 12-19-2013 01:19 AM by Han.)
Post: #4
RE: Invalid Input during local variable declaring
Get rid of the ":=" and replace them with just "=" when initializing local variables with a starting value.

As for variable limits -- it's 8 per instance of LOCAL regardless of initial values (16 bits used, half for local vars and the other half for corresponding initial values).

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
12-19-2013, 02:30 AM
Post: #5
RE: Invalid Input during local variable declaring
(12-19-2013 12:59 AM)Han Wrote:  Get rid of the ":=" and replace them with just "=" when initializing local variables with a starting value.

So, is the Prime Help incorrect, because it shows the syntax var_1:=value ?
Find all posts by this user
Quote this message in a reply
12-19-2013, 04:10 AM (This post was last modified: 12-19-2013 04:30 AM by Han.)
Post: #6
RE: Invalid Input during local variable declaring
(12-19-2013 02:30 AM)Michael de Estrada Wrote:  
(12-19-2013 12:59 AM)Han Wrote:  Get rid of the ":=" and replace them with just "=" when initializing local variables with a starting value.

So, is the Prime Help incorrect, because it shows the syntax var_1:=value ?

No, I'm the one who's incorrect. The "=" and ":=" are both acceptable. The issue he was having is that his whitespace was a different whitepspace from what the HP Prime accepts, among other issues (haven't quite fully debugged)

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
12-20-2013, 09:20 AM
Post: #7
RE: Invalid Input during local variable declaring
Hello,

No syntax error in the program. However some of your white spaces are NOT hex 20 (ie, normal) white spaces but are some unicode spaces...

I have no clue how they got there, but do a check on your program and you will see that each error is on a white space. do backspace and then space to replace them and then it works...

Unicode si a beast and so prone to errors with so many characters that look identical (or are), witout actually beeing the same!

Cyrille
Find all posts by this user
Quote this message in a reply
Post Reply 




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