Computer Science Canada

I need help (little thing)

Author:  bboy_ayz [ Sun Nov 27, 2005 1:25 pm ]
Post subject:  I need help (little thing)

Listen, i made a game basicly like who wants to be a millionaire.


So i put a question a)blala b)blalal .. u understand then i put

if one = "a" then
put "Nice"
dely (blblba)
cls

else
put "Sorry, you choose the wrong answer you have to leave"

now here i want to make the program exit.. i tried to put exit but it tells me its ment for loop or for i..

is there any way to make my program leave if the answer is worng?

Author:  Dan [ Sun Nov 27, 2005 1:42 pm ]
Post subject: 

1st off on this site the rules say you may not make topics with subject names that are not descripive of the problem or basily say "i need help". Somthing to keep in mind for next time you post.

now as for your problem, noramly in good progaming pratices you whould not need to do this. Uhsely one whould put all the code in a while loop such as:


while flag = true do

code here

end while loop


and when u whont to exit the progame or loop you set flag to flase.

But if you most i think the comand in turing to do what you whont in return but i am not shure of this.

Author:  bboy_ayz [ Sun Nov 27, 2005 2:43 pm ]
Post subject: 

man, i dont really get what you wrote

this is my script ( i have the question and option on top and i have vars, all good)

get one
if one = "c" then
delay (500)
put "Nice!"
score := score + 100
delay (1000)
cls
else
put "Wrong!!"
delay (500)
put "Sorry to tell you but you have to leave"
exit
end if
cls

can you tell me what to write so that if the answer is not "c" it will leave the program ?


thx

Author:  Cervantes [ Sun Nov 27, 2005 2:57 pm ]
Post subject: 

code:

else
    put "WRONG!"
    delay (500)
    return
end if


Alternatively, you could wrap everything in a loop, and exit it. It's sort of like faking a goto line.

Author:  Mystify [ Tue Nov 29, 2005 9:45 am ]
Post subject: 

What about...

loop
if "answer" = "a" then
put "Correct!!"
exit when "answer" = "b" or "c" or "d"
end loop

Author:  ZeroPaladn [ Tue Nov 29, 2005 9:58 am ]
Post subject: 

Mystify wrote:
What about...

loop
if "answer" = "a" then
put "Correct!!"
exit when "answer" = "b" or "c" or "d"
end loop


its more like...
[code="Turing"]loop
if awnser = "a" then
put "Correct!!"
exit when awnser = "b" or awnser = "c" or awnser = "d"
end loop
[/code]

Author:  Mystify [ Tue Nov 29, 2005 10:16 am ]
Post subject: 

yeah i thought it was like that i have my own who wants to be a millionaire game heres what i left off at just to give you an idea....

code:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%            Scripter: Mystify            %
%Game Name: Who Wants To Be A Millionaire %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var answer, name : string
colourback (black)
color (0)
cls
put " Welcome To Who Wants To Be A Millionaire"
delay (900)
put ""
put ""
put " What is your name"
get name:*
put ""
delay (2000)
put " Ok ", name, " Let's Start The Game"
delay (900)
put ""
put " For 100 dollars"
put ""
put " What is the name of the Govenor of California"
delay (1000)
put ""
put " Is it (a) 50 Cent (b) Missy Elliot (c) George Forman (d) Arnold Schwarzenegger"
get answer
put ""
if answer = "d" then
    delay (5000)
    color (10)
    put " Congrad's Thats The Correct Answer"
elsif
        answer = "a" then
    delay (5000)
    color (red)
    put " Sorry Thats The Wrong Answer Good Bye"
elsif
          answer = "a" then
    delay (5000)
    color (red)
    put " Sorry Thats The Wrong Answer Good Bye"
       
elsif
        answer = "c" then
    delay (5000)
    color (red)
    put " Sorry Thats The Wrong Answer Good Bye"
   
end if
put ""
put ""
color (0)
delay (900)
put " For 200 dollars"
put ""
put " Which of these companies made the Xbox and Xbox 360"
delay (1000)
put ""
put " Is it (a) Nintendo (b) Sony (c) Microsoft(d) Lexmark"
get answer
put ""
if answer = "c" then
    delay (5000)
    color (0)
    put " Congrad's Thats The Correct Answer"
elsif
        answer = "a" then
    delay (5000)
    color (0)
    put " Sorry Thats The Wrong Answer Good Bye"
elsif
          answer = "b" then
    delay (5000)
    color (0)
    put " Sorry Thats The Wrong Answer Good Bye"
elsif
          answer = "d" then
    delay (5000)
    color (0)
    put " Sorry Thats The Wrong Answer Good Bye"
   
end if





: