Computer Science Canada

Problem with Code - Help Please

Author:  Namis [ Thu Sep 11, 2003 2:56 pm ]
Post subject:  Problem with Code - Help Please

var one : string
var two : string
put " Yes or No? "
if one = "Yes" then
put " Good Choice! "
elsif two = "No" then
put " Bad Choice! "

im getting 1 error, what is wrong with this?

Author:  Namis [ Thu Sep 11, 2003 3:20 pm ]
Post subject:  Different Code

put " hello " ..
put " What is your name? "
put " my name is Andrew. "
put " How are you today? "
var fine : string
get fine
put " Well, Im doing Good " ..
put " Not exactly ", fine ..
put " though "
var game : string
var Yes : string
put " Want to play a game? " ..
put " Yes or No "
get game
if game = Yes then
put " Cool, lets play a game! "

else
put " Ok You dont want to play a game then "

end if

- OK This code works fine, but after user answers Yes/No, it finishes the program without saying " Lets play, or OK you dont want to play "

What am i doing wrong?? Any Help would be appreciated

Author:  Archi [ Thu Sep 11, 2003 4:01 pm ]
Post subject: 

When using if statements involving variables which are strings u need to include the " "....So the code for this which works will be:

put " hello " ..
put " What is your name? "
put " my name is Andrew. "
put " How are you today? "
var fine : string
get fine
put " Well, Im doing Good " ..
put " Not exactly ", fine ..
put " though "
var game : string
var Yes : string
put " Want to play a game? " ..
put " Yes or No "
get game
if game = "Yes" then
put " Cool, lets play a game! "

else
put " Ok You dont want to play a game then "

end if[/b]

Author:  Namis [ Thu Sep 11, 2003 6:11 pm ]
Post subject:  Thanks

Much Appreciated, ill give it a try now

Author:  Namis [ Thu Sep 11, 2003 6:18 pm ]
Post subject: 

This is what i got now, It works fine ( if i take the "No" Part out. )

[/code]put " hello " ..
put " What is your name? "
put " my name is Andrew. "
put " How are you today? "
var fine : string
get fine
put " Well, Im doing Good " ..
put " Not exactly ", fine ..
put " though "
var game : string
put " Want to play a game? " ..
put " Yes or No "
get game
if game = "Yes" then
put " Cool, lets play a game! "

elsif No = "No" then <---- Says No = Is An Error
put " Fine, Be that Way "
exit <--- Says Exit is an error.

end if



Anyone know why?

Author:  krishon [ Thu Sep 11, 2003 6:20 pm ]
Post subject: 

instead of doing elsif's all the time, u can do else. Else will take any other value other than yes in ur case and output a message. That way ppl will not hafta type in no all the time. And put ur varialbes at the top...its better that way so u know wut variables u use. This really helps when programs begin to get big

Author:  Dan [ Thu Sep 11, 2003 6:22 pm ]
Post subject: 

i think tony toald you this in another fourm, you need to have a var named No to check if it is equal to "no".

you are geting input in game for this so why not chage the No to game it should wrok.

also you could use an else stamet insted of elsif

Author:  krishon [ Thu Sep 11, 2003 6:23 pm ]
Post subject: 

lol, i beat u to it Laughing

Author:  Dan [ Thu Sep 11, 2003 6:25 pm ]
Post subject: 

ya i know Hit Wall

Author:  Namis [ Thu Sep 11, 2003 6:47 pm ]
Post subject:  K

Worked it out except for exit, im still getting an error message for exit

code:
else
put " Fine, Be that Way "
exit  <-------- Error

end if

Author:  krishon [ Thu Sep 11, 2003 6:52 pm ]
Post subject: 

exit only works with a loop...u dun't need it in ur program

Author:  Dan [ Thu Sep 11, 2003 6:52 pm ]
Post subject: 

try return, but i think this is bad progaming.

why not just put game code in the "yes" if?

Author:  krishon [ Thu Sep 11, 2003 6:55 pm ]
Post subject: 

isnt' return c++??

Author:  Tony [ Thu Sep 11, 2003 7:00 pm ]
Post subject: 

return sends you right to the end of your program... kind of equivalent to C++'s "press any key to quit".

if you want program to close, use
code:

quit

instead

Author:  krishon [ Thu Sep 11, 2003 7:00 pm ]
Post subject: 

oh ok

Author:  Namis [ Thu Sep 11, 2003 7:07 pm ]
Post subject: 

Thanks Tony, And Hacker Dan, sorry for the spam. Twisted Evil

Author:  Namis [ Thu Sep 11, 2003 7:13 pm ]
Post subject: 

Ill give you mr bits Kris, for your help Thanks.

Author:  krishon [ Thu Sep 11, 2003 7:15 pm ]
Post subject: 

u didn't need to...its fine...but thanks newayz...how much did u give me, lol

Author:  Namis [ Thu Sep 11, 2003 7:21 pm ]
Post subject: 

Heh, i dont care for them, and you have a nice collection going..
44

Author:  krishon [ Thu Sep 11, 2003 7:22 pm ]
Post subject: 

i'll give em back if u want

Author:  Namis [ Thu Sep 11, 2003 7:53 pm ]
Post subject: 

Nah like i said, i dont care for em, but thanks anyway

Author:  krishon [ Thu Sep 11, 2003 7:54 pm ]
Post subject: 

np...wow, 24 posts in a day not bad Wink

Author:  Namis [ Thu Sep 11, 2003 8:14 pm ]
Post subject: 

* cough * 25 *cough*


And Counting.. ;\

Do you use MSN or icq or something kris?

Author:  krishon [ Thu Sep 11, 2003 8:17 pm ]
Post subject: 

yup

my msn is ur_doom_2003@hotmail.com

Author:  octopi [ Thu Sep 11, 2003 8:37 pm ]
Post subject: 

Well heck, my post count would be over 500 if I used this as a chat instead of a forum.

Its not hard to write hundreads of posts, all less then 10 words....

Author:  Namis [ Thu Sep 11, 2003 8:44 pm ]
Post subject: 

var hate:string
put " Why do mods hate me ? "
get hate
put " That is not a good enough reason! " , hate
put " Cries *

Author:  octopi [ Thu Sep 11, 2003 8:49 pm ]
Post subject: 

Don't worry I don't count as a mod here.

I only go into the turing area's to cause trouble Razz

+1 bit for using turing code to speak.

Anyways....I am not directly talking about you. (I am, but I am not.)
In general people post too many topics saying.

"Cool"

"Yup"

etc.....It would be nice if people could say a little more maybe...
Am I the only one that thinks it would be better if people acctually put some effort in there responses?

The idea of this bb, is not who can post the quickest, smallest anwser.
Its who can post the best anwser.

Author:  AsianSensation [ Thu Sep 11, 2003 9:08 pm ]
Post subject: 

I concur whole-heartedly with octopi, do try to make educated posts, or else, people will likely to think that you spam too much, and "brand" you; and nothing you say afterward, even if they are actually useful stuff, will be looked upon, because people will just think you were spamming for bits or something.

An excellent example would be dodge_tomahawk, i didn't even bother to read his posts after some time. He might have changed now, since he has too many bits (wonder how he got them), but you never know.

Author:  Andy [ Thu Sep 11, 2003 9:28 pm ]
Post subject: 

hey azn, leave me alone, i havent been on this site for months, and all my bits were from my hard work of spamming, i used to have the highest post per day... anyhow turing is gay, gay gay, lol, no more turing for me...

Author:  Dan [ Thu Sep 11, 2003 9:42 pm ]
Post subject: 

omg, void and dodge come back in on the same day and now we got this new spamer. THE END OF THE WROLAD IS NEAR RUN FOR YOUR LIVES, WE ARE ALL GOING TO DIE, NOOOOOOOOOOO!!!!!!


now that spaming Wink

Author:  Andy [ Thu Sep 11, 2003 9:45 pm ]
Post subject: 

i'm not the only spammer? yay lucky u guys... lol and whos the new guy? btw azn spams alot too

Author:  Dan [ Thu Sep 11, 2003 9:47 pm ]
Post subject: 

meh, gets the sites post count up, lol. now lets stop spaming this topic to hell.

the spam fourm whould be nice for a topic on spaming Wink

every one move along nothing to see here

Author:  Andy [ Thu Sep 11, 2003 9:49 pm ]
Post subject: 

i would spam on the spamming section, but there is no point, i dun get spam count and i dun get bits, but i will stop spamming here and find a new home...

Author:  Namis [ Fri Sep 12, 2003 2:57 pm ]
Post subject: 

My Stuff isnt spam , its alternative to PM ;p
Plus is someone doesnt know, someone else might

Shocked I like that Face Shocked

Author:  Dan [ Fri Sep 12, 2003 4:15 pm ]
Post subject: 

Namis wrote:
My Stuff isnt spam , its alternative to PM ;p
Plus is someone doesnt know, someone else might

Shocked I like that Face Shocked


Then what the hell you call what you just posted there????

i am not calling your questions spam, they are fine. it is just when you post stuff like:

Quote:

Paul, its Andy.. Ill send you an email ;\


in a new topic in turing help i get mad and call that spam.

now this topic has gone to fare.....

*dan borws asok's locking gun*
LOCKED!!!!!


: