Computer Science Canada

Hello. need to end program

Author:  darkshade [ Thu Sep 13, 2007 11:21 am ]
Post subject:  Hello. need to end program

hello. in my program i need to know how to get it to finish in a if statment.

here is my code so far. i have commeted on the area i need it to end in. please help.

Turing:

var math1,math2,math3:string
var input1,input2,input3:int
math1:="5+5"
math2:="10+10"
math3:="20+20"
input1:=0
input2:=0
input3:=0
proc quiz1
put "What is ",math1
get input1
end quiz1

proc quiz2
put "What is ",math2
get input2
input1:=0
end quiz2

proc quiz3
put "What is ",math3
get input3
input2:=0
end quiz3

proc done
put "Congrats"
end done

proc input
if (input1=10) then
quiz2
elsif (input2=20) then
quiz3
elsif (input3=40) then
done
else
put "FAIL"
%i need it to finish at this point. i do not know the command.
end if
end input

proc main
quiz1
input
input
input
end main
main

Author:  CodeMonkey2000 [ Thu Sep 13, 2007 11:51 am ]
Post subject:  RE:Hello. need to end program

Try adding quit.

Author:  darkshade [ Thu Sep 13, 2007 12:02 pm ]
Post subject:  Re: Hello. need to end program

Thank you sooooo much. i have tryed everything else! finish, break,end, exit! thank you! it works now!

Author:  Carey [ Mon Sep 24, 2007 12:19 pm ]
Post subject:  Re: Hello. need to end program

You can also use return. return is better because when you compile it into an *.exe with the option "Immediately close run window" it only exits and doesn't say "Error: Quit#1" and die. however when return is used in a procedure, function, etc, it only exits that proc. In order for it to finish a program it has to be on the main level (not in a proc or other).


: