Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: hellninjas on January 30, 2012, 11:58:13 pm
-
How would I do...
If (/*USER INPUT*/) = "Suicide" :Disp "You Died" ???
This has been troublesome to me...
Also is there any more variables I can use instead of just a-z?
Like if I could do... HOLY->235
or something...
Thanks :D/me just realized he hasn't done basic in a while!
I'm glad to be back :D!!
-
This is BASIC correct?
You would do:
Input "",Str1
If Str1 = "SUICIDE":Disp "You Died"
-
Input "",Str1
If Str1 = "SUICIDE":Disp "You Died"
else :Disp "Incorrect command"
Could this work?
-
Yeah, that should work, sorry for the late reply
-
Input "",Str1
If Str1 = "SUICIDE":Disp "You Died"
else :Disp "Incorrect command"
Could this work?
Nope. If you are using an Else, Then you need a Then then an End.
A correct (non optimized) code would be
Input "",Str1
If Str1="SUICIDE"
Then
Disp "You Died"
Else
Disp "Incorrect command"
End
And an optimized code would be
Input "",Str1
"Incorrect command"
If Str1="SUICIDE":"You Died"
Disp Ans
-
And an optimized code would be
Input "",Str1
"Incorrect command"
If Str1="SUICIDE":"You Died"
Disp Ans
More optimized!
Input "",Str1
"Incorrect command
If Str1="SUICIDE
"You Died
Disp Ans
The strings could be changed to uppercase, but that would change the output.