If statements with more than one word
Author |
Message |
aogborne
|
Posted: Wed Mar 30, 2016 8:14 am Post subject: If statements with more than one word |
|
|
What is it you are trying to achieve?
i'm trying to make a text based game with using more than one word in a n IF statement if possible
What is the problem you are having?
it doesn't register anythign being entered
Describe what you have tried to solve this problem
googled, tutorials, if I change it to one word it works but not 2
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
var choice : string
put "what do you want to do"
get choice
if choice = "go north" then
put "north"
elsif choice = "take item" then
put 'item'
else
put 'ok'
end if
|
Please specify what version of Turing you are using
4.1.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dreadnought
|
Posted: Wed Mar 30, 2016 3:08 pm Post subject: Re: If statements with more than one word |
|
|
Notice what happens if you type "go north" into the program below (and hit enter):
Turing: | var choice : string
put "what do you want to do"
get choice
put "You typed \"", choice, "\"" |
As you can see get stops at the first whitespace character (space, tab, newline, ...).
You want get to read the entire line. To do this we add a colon and asterisk as so
For more details (like what happens if you use a number instead of an asterisk) see the documentation for get. |
|
|
|
|
|
aogborne
|
Posted: Tue Apr 12, 2016 8:32 am Post subject: RE:If statements with more than one word |
|
|
i forgot to thank you so here are some bits. +2 bits
i don't have many but enjoy.
tahnsk you dreadnought! |
|
|
|
|
|
|
|