Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Hi and thanks for taking time and helping me out. I am writing a program to play Battleship in TI-BASIC. It's an amateuristic program, so don't judge me on my bad thinking or anything. I am from the Netherlands, so don't judge me on my English either Very Happy

On to the program: I have put this BETA version on my TI84+, but it had an SYNTAX error in the last line, line 74 (End command). It somehow won't work, but I don't know why. It would be great if you could help me, so I can go on with my program. Thank you in advance.


Code:
ClrHome
Disp "PASSWORD","PLAYER 1","4 NUMBERS"
Prompt P
[[0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0]]->[A]
[A]->[B]
ClrDraw
FnOff
PlotsOff
0->Xmin
10->Xmax
0->Ymin
10->Ymax
Horizontal 1
Horizontal 2
Horizontal 3
Horizontal 4
Horizontal 5
Horizontal 6
Horizontal 7
Horizontal 8
Horizontal 9
Horizontal 10
Vertical 1
Vertical 2
Vertical 3
Vertical 4
Vertical 5
Vertical 6
Vertical 7
Vertical 8
Vertical 9
Vertical 10
Disp "LAY DOWN","YOUR SHIPS"
Disp "1,1 IS","BOTTOMLEFT"
0->N
Repeat N=17
Menu("PLACEMENT","NEW START",AN,"UP",AU,"RIGHT",AR,"DOWN",AD,"LEFT",AL)
Lbl AN
DispGraph
Pause
Prompt X,Y
1->[A](X,Y)
Pt-On(X-.5,Y-.5)
Pause
N+1->N
End
Lbl AU
Y+1->Y
1->[A](X,Y)
Pt-On(X-.5,Y-.5)
Pause
N+1->N
End
Lbl AR
X+1->X
1->[A](X,Y)
Pt-On(X-.5,Y-.5)
Pause
N+1->N
End
Lbl AD
Y-1->Y
1->[A](X,Y)
Pt-On(X-.5,Y-.5)
Pause
N+1->N
End
Lbl AL
X-1->X
1->[A](X,Y)
Pt-On(X-.5,Y-.5)
Pause
N+1->N
End
Which control structure is the End supposed to be Ending? You don't need one just to exit the program.
No, it's only part of the game. It is supposed to end the Repeat N=17. After this, player 2 has to lay down his ships.
Okay, you only have 1 item that requires End, and you have multiple Ends. So that is going to cause some issues. Also, Menu (and Goto) inside a loop is a bad idea, creates a memory leak, so that'd be something you'd want to change.

So, basically, any time you have a Repeat, While, For( or If:Then, you just use one End command per. Otherwise, the calculator will throw the error, because it runs across the End, but it doesn't have anything to show calling for the End.
Oh I get it. That was pretty dumb indeed. Thank you!
Not a problem. Smile

Might I recommend, you have a list of Horizontal and Vertical. You can shorten that with a For( loop

For(F,1,10
Horizontal F
End

If you want any help with getting away from the Menu and Lbl stuff to use loops, I'm sure we can direct you towards some code that will help you out. Or a good book.
  
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