Hello, I've been programming my TI84 Plus on the Ti-Basic Developer website where they have game programs to follow. Even though I follow it exactly as written, I keep getting ERR:Domain. Any ideas what could be going on?
Thank you
Can you show us (either here or in PMs) some example code? Output() cannot have a value of 0 in the x or y parameter.
I might be able to help, but you could please provide some further information. Like, what program? Or what does the code look like? This information would be very useful to anyone who might be interested in helping.
ShinyGardevoir wrote:
Can you show us (either here or in PMs) some example code? Output() cannot have a value of 0 in the x or y parameter.


This is it:
:ClrHome
:Disp "PAPER - SCISSORS
:Input "ROUNDS:",I
:For(I,1,I
:ClrHome
:Disp "CHOOSE WEAPON:
:Disp "1) ROCK","2) PAPER","3) SCISSORS
:Repeat 2>abs(Ans-2
:getKey-91→J
:End
:Disp "YOU: "+sub("ROCK PAPER SCISSORS",8J-7,8
:randInt(1,3
:Disp "CALC: "+sub("ROCK PAPER SCISSORS",8Ans-7,8
:Pause "WINNER IS "+sub("YOU CALCBOTH",1+4max(Ans={1,2,3} and J={3,1,2})+8(J=Ans),4
:End
:ClrHome:"

Getting the err:domain on the :Disp "YOU: "+sub("ROCK PAPER SCISSORS",8J-7,8 line.
That's because it's trying to get 8 characters starting from "ORS"; an error is thrown because there are no more characters to meet the 8 character substring.
It looks like you need to add-in extra spaces inside the string ("ROCK PAPER SCISSORS") unless I'm reading it wrong. Adding-in the extra spaces (making it so each word is equal to 8 characters) will prevent the calculator from trying to recall a substring that's past the length of the original string. That's what's causing a domain error.
ShinyGardevoir wrote:
That's because it's trying to get 8 characters starting from "ORS"; an error is thrown because there are no more characters to meet the 8 character substring.


Thank you!
RoccoLox Programs wrote:
It looks like you need to add-in extra spaces inside the string ("ROCK PAPER SCISSORS") unless I'm reading it wrong. Adding-in the extra spaces (making it so each word is equal to 8 characters) will prevent the calculator from trying to recall a substring that's past the length of the original string. That's what's causing a domain error.


Thank you!
I used one space, so I'll try it again with two spaces.
RJNC wrote:
I used one space, so I'll try it again with two spaces.

Do this: "ROCK(4 spaces)PAPER(3 spaces)SCISSORS". That should prevent a domain error from being thrown out by the calculator.
EDIT: You'll need to do the same thing to this line:

Code:
:Disp "CALC: "+sub("ROCK PAPER SCISSORS",8Ans-7,8
You can also save some space and do "ROCK PAPER SCISSORS" -> Str1, Str2, etc. so you wouldn't have to modify the string twice if you just used string variables.
I tried the spaces, that didn't work. Thanks for the help though.
ShinyGardevoir wrote:
You can also save some space and do "ROCK PAPER SCISSORS" -> Str1, Str2, etc. so you wouldn't have to modify the string twice if you just used string variables.

I'm not sure what you mean by Str1 etc...
Judging from the code:

Code:

:ClrHome
:Disp "PAPER - SCISSORS
:Input "ROUNDS:",I
:For(I,1,I
:ClrHome
:Disp "CHOOSE WEAPON:
:Disp "1) ROCK","2) PAPER","3) SCISSORS
:Repeat 2>abs(Ans-2
:getKey-91→J
:End
:Disp "YOU: "+sub("ROCK PAPER SCISSORS",8J-7,8
:randInt(1,3
:Disp "CALC: "+sub("ROCK PAPER SCISSORS",8Ans-7,8
:Pause "WINNER IS "+sub("YOU CALCBOTH",1+4max(Ans={1,2,3} and J={3,1,2})+8(J=Ans),4
:End
:ClrHome:"

You can replace some of the duplicate strings with a variable like Str1. To access that, do [Vars][7][1].

Code:

:ClrHome
"ROCK    PAPER   SCISSORS→Str1
:Disp "PAPER - SCISSORS
:Input "ROUNDS:",I
:For(I,1,I
:ClrHome
:Disp "CHOOSE WEAPON:
:Disp "1) ROCK","2) PAPER","3) SCISSORS
:Repeat 2>abs(Ans-2
:getKey-91→J
:End
:Disp "YOU: "+sub(Str1,8J-7,8
:randInt(1,3
:Disp "CALC: "+sub(Str1,8Ans-7,8
:Pause "WINNER IS "+sub("YOU CALCBOTH",1+4max(Ans={1,2,3} and J={3,1,2})+8(J=Ans),4
:End
:ClrHome:"
ShinyGardevoir wrote:
Judging from the code:

Code:

:ClrHome
:Disp "PAPER - SCISSORS
:Input "ROUNDS:",I
:For(I,1,I
:ClrHome
:Disp "CHOOSE WEAPON:
:Disp "1) ROCK","2) PAPER","3) SCISSORS
:Repeat 2>abs(Ans-2
:getKey-91→J
:End
:Disp "YOU: "+sub("ROCK PAPER SCISSORS",8J-7,8
:randInt(1,3
:Disp "CALC: "+sub("ROCK PAPER SCISSORS",8Ans-7,8
:Pause "WINNER IS "+sub("YOU CALCBOTH",1+4max(Ans={1,2,3} and J={3,1,2})+8(J=Ans),4
:End
:ClrHome:"

You can replace some of the duplicate strings with a variable like Str1. To access that, do [Vars][7][1].

Code:

:ClrHome
"ROCK    PAPER   SCISSORS→Str1
:Disp "PAPER - SCISSORS
:Input "ROUNDS:",I
:For(I,1,I
:ClrHome
:Disp "CHOOSE WEAPON:
:Disp "1) ROCK","2) PAPER","3) SCISSORS
:Repeat 2>abs(Ans-2
:getKey-91→J
:End
:Disp "YOU: "+sub(Str1,8J-7,8
:randInt(1,3
:Disp "CALC: "+sub(Str1,8Ans-7,8
:Pause "WINNER IS "+sub("YOU CALCBOTH",1+4max(Ans={1,2,3} and J={3,1,2})+8(J=Ans),4
:End
:ClrHome:"


Thank you so much! I feel bad asking all these questions, you folks are awesome!
  
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