Here's a snippet of code from one of my programs:


Code:
SetUpEditor |LHST
SetUpEditor |LPOS
0->Xmin
~62->Ymin
94->Xmax
0->Ymax
1->N
ClrDraw
ClrHome
1->G
~1->H
45->I
Lbl MN
Line(G,H,I,H
Line(I,H,I,H-28
Line(I,H-28,G,H-28
Line(G,H-28,G,H
RecallPic 6
Repeat K=21 or K=24 or K=25 or K=26 or K=34
   getKey->K
End
If K=24
Then
   If G=1 and (H=~1 or H=~33
   Goto MN
   Else
   G-48->G
   I-48->I
End
If K=25
Then
   If H=~1 and (G=1 or G=49
   Goto MN
   Else
   H+32->H
End
If K=26
Then
   If G=49 and (H=~1 or H=~33
   Goto MN
   Else
   G+48->G
   I+48->I
End
If K=34
Then
   If H=~33 and (G=1 or G=49
   Goto MN
   Else
   H-32->H
End
ClrDraw
Goto MN


The K=21 bit hasn't been added yet, but it shouldn't matter for this question.

What this is supposed to do is move a little box around the screen depending on which arrow keys one presses. The problem is: it's not. It starts off by displaying the box, but when any arrow key is pressed, the box disappears. The 2nd key just clears the screen and redraws everything that was there before, as expected. There is a picture variable (Pic6) accompanying it.

Any ideas? This used to work, but I made a few changes and it no longer does.
It seems you miss a "Then" in the 4 blocks of code that checks for a key.


Code:
If K=26
Then
   If G=49 and (H=~1 or H=~33
   Goto MN
   Else
   G+48->G
   I+48->I
End

should be this:

Code:
If K=26
Then
   If G=49 and (H=~1 or H=~33
   Then
     Goto MN
   Else
     G+48->G
     I+48->I
  End
End


If not, just say it Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement