I know that it's probably something really easy, but here's the code:


Code:
ClrHome
1->A
1->B
0->K
For(B,1,10)
   Output(B,1,"OOOOOOOOOOOOOOOOOOOOOOOOOO")
End
Output(B,A,"X")
Repeat 1=0
   getKey->K
   If not(K=0)
   Then
      If K=25 and not(B=1) //up
      Then
         Output(B,A,"O")
         B+1->B
         Output(B,A,"X")
      End
      If K=26 and not(A=26) //left
      Then
         Output(B,A,"O")
         A+1->A
         Output(B,A,"X")
      End
      If K=24 and not(A=1) //right
      Then
         Output(B,A,"O")
         A-1->A
         Output(B,A,"X")
      End
      If K=34 and not(B=10) //down
      Then
         Output(B,A,"O")
         B-1->B
         Output(B,A,"X")
      End
      If K=23 //del
      Then
         ClrHome
         Stop
      End
   End
End


I am getting a domain error on line 8 (Output(B,A,"X")), but I don't understand what could possibly be wrong. This is supposed to put an X on the screen with everything else Os and allow you to move it around with the arrows. I would really appreciate some help on this!
At the end of the first For( loop, B has a value of 11, since the value of B needs to exceed 10 to quit the loop. Because the screen only has 10 rows to display text, a domain error occurs when trying to print on an 11th row.

Hopes this helps!
Also, remember to use the [code] brackets when posting code. It makes it a lot easier for us (and you) to figure out what is wrong. Smile

P.S. Welcome to Cemetech. Hope you enjoy it here.
  
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 GMT - 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