Computer Science Canada if statement (i got no answers from tutuorial section... |
Author: | battleroyale [ Mon Apr 11, 2005 7:54 pm ] |
Post subject: | if statement (i got no answers from tutuorial section... |
i have to repost this here.... hello everyone....I AM A NOOB AT TURING....im trying to master (or at least understand the basics) of turing for my computer science class....im writing a simple "chat" program that you input names, dates, ages, etc and its like a chat room. Now iwant to do some yes and no questions with different answers...can anyone help me on how to put if statements in..like if ...this then ....that end if or if ...that then ...this end if w/e....thanks alot BR |
Author: | Vertico [ Mon Apr 11, 2005 8:07 pm ] | ||
Post subject: | |||
Im not sure what u mean so ill just give u a very easy example.
|
Author: | battleroyale [ Mon Apr 11, 2005 8:29 pm ] |
Post subject: | |
that accually helped alot...but what if the question was like a yes or no...and if you answered something else it wouldnt work...like you need to ask them again..you loop it right? but when they answer in yes or no...how do you get out of the loop? Where do you put the loop and end loop? var ques1:string put "Do you think halo sucks? ", "yes or no?" get ques1:* if ques1 = "yes" then put "good job...cs rules" elsif ques1 = "no" then put "Why do you like bad games for?" else put "you have to answer yes or no" end if |
Author: | marshymell0 [ Mon Apr 11, 2005 8:47 pm ] | ||||
Post subject: | |||||
if you want to ask the same question over and over again, put loop at the beginning after you declare the variable. THerefore, you get
If you want to exit the loop, then you need an exit when statement, for example, if you want the program to end after you answer yes, you put
|
Author: | Tony [ Tue Apr 12, 2005 8:43 am ] |
Post subject: | |
exit when condition[i] is equivalent of if [i]condition then exit Anyways, battleroyale -- if you don't know how to use if statement, don't try to make a chat program. There are too many things that you're not familiar with yet. |
Author: | StarGateSG-1 [ Tue Apr 12, 2005 10:59 am ] |
Post subject: | |
You shouldn't even be using If statments for a chat program you shoudl be learning case, process, procedure, module, serevrs, clients. Until you knwo all that stuff go back to turing for begineer's. WNating to make really nice programs is just as bad as wanting to make hacks. You people need to understand that your are intaneous a programing genious they are very few and far between. |
Author: | Martin [ Tue Apr 12, 2005 12:57 pm ] |
Post subject: | |
if and case are the same thing in turing. |
Author: | battleroyale [ Tue Apr 12, 2005 7:49 pm ] |
Post subject: | |
yo..no need to yell at me...i now i am noob...by chat program i meant like you are talking to someone...like if they ask you a question and you answer yes or no...like that....omg...people are so mean. Ok i have another question...stupid maybe...for my computer science homework...my teacher gave me like 10 questions..i finished them all (it was simple problems where user puts in numbers like age, money, etc. and you calculate them) What i want to do is first put a question like "WHich question would you like to see?" and then you got the questions listed. I wrote that and put the if ques1="8" (example) then........ what do i do....cuz for c++ my friend told me you could tell it to "GO TO" a specific line and run in from there. Is there something like that too? or do i have to just put in the entire question 8 after then? Thanks again for helping and not flaming... BR |
Author: | Tony [ Tue Apr 12, 2005 8:51 pm ] |
Post subject: | |
you can't go to a specific line -- that's not proper programming |
Author: | [Gandalf] [ Tue Apr 12, 2005 11:20 pm ] |
Post subject: | |
That's BASIC (old stuff) what you have to understand is that you can do everything that you would have done on the line you GOTO'ed in an if statement or something of the sort. BASIC: 10 Input "Name?"; name 20 If name = gandalf then goto 40 30 BLAH BLAH 40 print "hi" (blah, something like that, its been a while...) Turing: var name : string put "Name?" get name if name = "gandalf" then put "hi" else put "nothing" end if something like that can be used for much larger programs too - just experiment and youll get the concept soon enough! ![]() btw, Halo AND CS both suck so your program is flaud. |
Author: | battleroyale [ Wed Apr 13, 2005 1:34 pm ] |
Post subject: | |
i knew that already...but you see...i have 10 different types of programs and i want to make a "menu" for it....what is the easiest way to make one. the programs are like 5-10 lines long (for school) and i want to make a menu....so like i ask. "which question would you like to see". THen i list the numbers....and the user put like 1 or w/e. then it jumps to that... |
Author: | jamonathin [ Wed Apr 13, 2005 2:04 pm ] |
Post subject: | |
The best idea I saw was from andy. Compile each program (run [not f1], then generate stand-alone, then ok) and have a new program named 'menu' run each of your questions. use Sys.Exec to open the programs up. If that's too complicated, then make one program that includes every question in it. |
Author: | Martin [ Wed Apr 13, 2005 2:29 pm ] | ||
Post subject: | |||
|
Author: | battleroyale [ Wed Apr 13, 2005 5:30 pm ] | ||
Post subject: | |||
martin you just saved me sooo much time this is what i did first for my "menu"
as you can see...very confusing because it goes all the way up to ten. but after the proc and end blah it got so much simplier. Thanks alot. Now to learn how to do the infamous GUI. any links will be appreciated. [/code] |
Author: | Hikaru79 [ Wed Apr 13, 2005 9:54 pm ] |
Post subject: | |
battleroyale wrote: Thanks alot. Now to learn how to do the infamous GUI. any links will be appreciated. [/code] No, no, please don't. I don't want to come accross as mean as you seem to have interpreted some other comments. But the Turing GUI is one of the most convoluted and confusing modules in Turing. Please, before you attempt it, get some more basics under your belt. I'm not insulting your intelligence, just that going from if statements to GUI is a bit of a leap. Ask more questions here =) Work your way up, baby steps. |
Author: | battleroyale [ Thu Apr 14, 2005 1:07 pm ] |
Post subject: | |
so what shuld i learn now? |
Author: | Martin [ Thu Apr 14, 2005 1:11 pm ] |
Post subject: | |
How to use procedures and functions. After that, learn about classes, and finally learn about pointers. |
Author: | battleroyale [ Thu Apr 14, 2005 5:37 pm ] |
Post subject: | |
alright...procedures dont...i actually got the basics of GUI. ![]() now im trying to make a lottery game and first problem i got is how to make it so that the numbers you can choose are only between 1-10 i tried putting var number : int:=(1,69) but that didnt work...what should i do? ![]() ALso how do you make it so that if statements can contain more then one = like if blah="a" or "b" or "c" cuz that doesnt work...but it makes sence though.... |
Author: | Martin [ Thu Apr 14, 2005 6:20 pm ] |
Post subject: | |
Look up Rand.Int |
Author: | battleroyale [ Thu Apr 14, 2005 9:06 pm ] |
Post subject: | |
i understand random number already...i just don tknow how to put constraints on the numbers you can choose |
Author: | jamonathin [ Fri Apr 15, 2005 7:46 am ] | ||||
Post subject: | |||||
You cant put:
You need to put whatever again.
|
Author: | Martin [ Fri Apr 15, 2005 8:12 am ] |
Post subject: | |
This is because if statements function as follows if [statement 1] = true or [statement 2] = true or ... then So what your if statement 'if blah="a" or "b" or "c" ' translates to is: if (blah = "a") = true or ('b' = true) or ('c' = true) then .. as you see, although your statement makes sense in english, it doesn't make much sense in Turing. |
Author: | battleroyale [ Fri Apr 15, 2005 2:02 pm ] |
Post subject: | |
ok thanks.....i got it.... NOW lol...how do you make a counter? i cant find the thread...someone give me the link |
Author: | [Gandalf] [ Fri Apr 15, 2005 5:26 pm ] | ||||
Post subject: | |||||
Quote: If whatever = "this" or whatever = "that" then
hehehe, I didn't know that, I just used case statements - thanks! ![]() What do you mean by counter?
or
both of those can be considered counters? *edit* grr, thats two of those kinds of posts I've had to do in the same topic ![]() |
Author: | acidburn90 [ Wed Apr 20, 2005 9:47 pm ] |
Post subject: | |
yeh thats true... ive been working on turing for a long time (7 months) and i still sometimes have troubles with the GUI... also one more thing... someone in this forums did some pretty bad programming... its bad programming to put [code] if answer:= "quit" then exit [/code] its exit when answer:= "quit" just making u didnt get i9t mixed for anything major[/quote] |