Author Topic: Invalid Input during local variable declaring [HP PPL]  (Read 6511 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Invalid Input during local variable declaring [HP PPL]
« on: December 18, 2013, 06:27:21 pm »
I wonder if this is a bug or something I am doing wrong, but here's my code:

Code: [Select]
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, A-Z vars (which makes the code more confusing and isn't good practice).
« Last Edit: December 18, 2013, 06:29:06 pm by DJ Omnimaga »

Offline quitte

  • LV2 Member (Next: 40)
  • **
  • Posts: 22
  • Rating: +1/-0
    • View Profile
Re: Invalid Input during local variable declaring [HP PPL]
« Reply #1 on: December 18, 2013, 07:17:26 pm »
Maybe one of those variable names is already used with a different type? The mem view should be able to tell you.

Offline Han

  • LV3 Member (Next: 100)
  • ***
  • Posts: 62
  • Rating: +7/-0
    • View Profile
Re: Invalid Input during local variable declaring [HP PPL]
« Reply #2 on: December 18, 2013, 07:20:17 pm »
For any type of variable declaration that also includes an initial value, don't use the := and instead use only =

So:

LOCAL x=2, y=3;

is ok, but:

LOCAL x:=2, y:=3;

is not correct.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Invalid Input during local variable declaring [HP PPL]
« Reply #3 on: December 18, 2013, 07:28:24 pm »
ok thanks. By the way, would A=A+1 work elsewhere or not? Having to type the : at the start everytime is getting annoying. >.< (although it's nowhere as bad as the sto symbol, which has no keyboard character assigned to it).

However, it seems that my issue was because I used more than 4 vars with a value in one LOCAL statement. The limit is 4 (or 8 if they have no value). This is Michael on MoHPC who told me. http://www.hpmuseum.org/forum/thread-161-post-767.html#pid767

Thanks anyway for the tip!
« Last Edit: December 18, 2013, 07:29:16 pm by DJ Omnimaga »

Offline Han

  • LV3 Member (Next: 100)
  • ***
  • Posts: 62
  • Rating: +7/-0
    • View Profile
Re: Invalid Input during local variable declaring [HP PPL]
« Reply #4 on: December 18, 2013, 08:18:22 pm »
A:=A+1;

is fine. The ":=" is only for storing values into already-declared variable (or built-in system variable). The "=" is used for assignment during declaration. Otherwise, "=" is used to designate equality (so can be used as a boolean test in some cases).

As for the limit, it is 8, not 4. Only 16 bits allocated for declarations, 8 for variables, and another 8 for the corresponding initial values.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Invalid Input during local variable declaring [HP PPL]
« Reply #5 on: December 18, 2013, 08:26:09 pm »
Ok thanks for the info :)

Offline MacBernick

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +3/-0
    • View Profile
Re: Invalid Input during local variable declaring [HP PPL]
« Reply #6 on: December 18, 2013, 10:53:35 pm »
For any type of variable declaration that also includes an initial value, don't use the := and instead use only =

So:

LOCAL x=2, y=3;

is ok, but:

LOCAL x:=2, y:=3;

is not correct.

Really ? I use LOCAL x := y syntax in my program and it seems to work well.

Offline Han

  • LV3 Member (Next: 100)
  • ***
  • Posts: 62
  • Rating: +7/-0
    • View Profile
Re: Invalid Input during local variable declaring [HP PPL]
« Reply #7 on: December 18, 2013, 11:03:43 pm »
I stand corrected. Odd, for some reason I had it ingrained that it had to be = and not := but it does work as you say. Even for EXPORT!

Offline Han

  • LV3 Member (Next: 100)
  • ***
  • Posts: 62
  • Rating: +7/-0
    • View Profile
Re: Invalid Input during local variable declaring [HP PPL]
« Reply #8 on: December 18, 2013, 11:08:40 pm »
I found your problem. It's a whitespace issue that I had already reported. It's not the LOCAL statement at all, but a matter of the whitespace used by the forum not be interpreted as whitespace accepted by the HP Prime!!