Need help on a single line of code
Author |
Message |
blankout
|
Posted: Tue Mar 03, 2009 6:58 pm Post subject: Need help on a single line of code |
|
|
for some reason i cannot run my program if i input "no" into the first field. if i put "yes" it works fine but i can't seem to get it to work with "no" here's my code:
Turing: | var answer : string
var serve : string
var gender : string
var lastname : string
locate (12, 22)
put "My name is Jeeves. I am your personal butler"
delay (2000)
cls
locate (12, 30)
put "Can I ask you a few questions?"
locate (13, 39)
get answer
cls
if answer = "yes"
then
put "what is your lastname?"
get lastname
cls
put "What is your gender?"
get gender
cls
if gender = "male"
then
put "Hello Mr. ", lastname
put "how may I be of service?"
get serve
put "yes, Sir, right away Sir, i will get ", serve
put "at once"
end if
if gender = "female"
then
put "Hello Mrs. ", lastname
put "how may I be of service?"
get serve
put "yes, Madam, right away Madam, i will get ", serve
put "at once"
end if
if answer = "no"
then
put "Why not? Do you not want to have your own personal butler?"
end if
end if |
Mod Edit: Remember to use syntax tags! Thanks code: | [syntax="turing"]Code Here[/syntax] |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
BigBear
|
Posted: Tue Mar 03, 2009 7:02 pm Post subject: RE:Need help on a single line of code |
|
|
Because your if statement to check if they said no is inside the if statement to check if they said yes.
EDIT: it helps to press F2 while in turing it will show the if statements as indents and you can see where you problem is |
|
|
|
|
|
blankout
|
Posted: Tue Mar 03, 2009 7:11 pm Post subject: Re: Need help on a single line of code |
|
|
ok great thanks, now if i were trying to do something like if answer does not equal yes or no, how would i do that? |
|
|
|
|
|
BigBear
|
Posted: Tue Mar 03, 2009 7:14 pm Post subject: RE:Need help on a single line of code |
|
|
You could put
if answer not = "yes" and answer not = "no" then
but you should use
Turing: | if answer = "yes then
elsif answer = "no" then
else
%whatever
end if |
|
|
|
|
|
|
blankout
|
Posted: Tue Mar 03, 2009 7:17 pm Post subject: Re: Need help on a single line of code |
|
|
thank you, i've been working on this code for about 2 days. i know its a long time but i'm trying to get it perfected
thanks a lot. |
|
|
|
|
|
|
|