Author |
Message |
hamid14
|
Posted: Wed Oct 07, 2009 4:26 pm Post subject: Procedure Quiz1 may only be declared... |
|
|
What is it you are trying to achieve?
Trying to make it so that when the user types in "no", without quotes of course, it makes turing call up procedure quiz1
What is the problem you are having?
It has error on the procedure and says this:
'procedures' may only be declared at the program, module or monitor level
Describe what you have tried to solve this problem
I've tried putting the code in different areas
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
procedure quiz1
put "Here is question 1!"
end quiz1
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
|
Sponsor Sponsor
|
|
|
DemonWasp
|
Posted: Wed Oct 07, 2009 6:13 pm Post subject: RE:Procedure Quiz1 may only be declared... |
|
|
Make sure that the code you posted isn't inside a loop or other procedure. |
|
|
|
|
|
hamid14
|
Posted: Wed Oct 07, 2009 8:49 pm Post subject: Re: Procedure Quiz1 may only be declared... |
|
|
It's not inside a loop or another procedure. |
|
|
|
|
|
Tony
|
Posted: Wed Oct 07, 2009 9:35 pm Post subject: RE:Procedure Quiz1 may only be declared... |
|
|
Can we see all the code above "procedure quiz1 " ? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Kharybdis
|
Posted: Thu Oct 08, 2009 2:04 pm Post subject: RE:Procedure Quiz1 may only be declared... |
|
|
It seems that you have another procedure that isn't placed correctly in your code, and not the actual "procedure quiz1" that's causing it. As Tony said, post the actual code please. |
|
|
|
|
|
hamid14
|
Posted: Thu Oct 08, 2009 2:53 pm Post subject: Re: Procedure Quiz1 may only be declared... |
|
|
%Quiz #1 Variables
var q1 : string
var qanswer1 : int
var qanswer2 : string
var qanswer3 : string
%Quiz #1 GET READY!
proc quiz1
put "There are 3 questions in total. Get even one wrong, you will have to start the game over!"
get q1
put "The first question!"
get q1
put "How many health points does the Blue Beast have?"
get qanswer1
if qanswer1 = 4 then
put "Correct! Here is the next question!"
get q1
put "What does BIOS stand for?"
get qanswer2
if qanswer2 = "basic input output system" then
put "Right again! Here is the last question!"
get q1
put "What is 3*3*5+2+3+4-1-1 X TAN37 + SIN42 + COS12! No rounding please! >"
get qanswer3 |
|
|
|
|
|
Tony
|
Posted: Thu Oct 08, 2009 3:16 pm Post subject: RE:Procedure Quiz1 may only be declared... |
|
|
that is clearly missing a bunch of code... where's the rest of it? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
hamid14
|
Posted: Thu Oct 08, 2009 3:33 pm Post subject: Re: Procedure Quiz1 may only be declared... |
|
|
Here's the whole thing:
%Quiz #1 Variables
var q1 : string
var qanswer1 : int
var qanswer2 : string
var qanswer3 : string
%Quiz #1 GET READY!
proc quiz1
put "There are 3 questions in total. Get even one wrong, you will have to start the game over!"
get q1
put "The first question!"
get q1
put "How many health points does the Blue Beast have?"
get qanswer1
if qanswer1 = 4 then
put "Correct! Here is the next question!"
get q1
put "What does BIOS stand for?"
get qanswer2
if qanswer2 = "basic input output system" then
put "Right again! Here is the last question!"
get q1
put "What is 3*3*5+2+3+4-1-1 X TAN37 + SIN42 + COS12! No rounding please! >"
get qanswer3
if qanswer3 = "124.84327737416381645909741941325" then
put "You got them all, eh? Next time! It'll be harder! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Thu Oct 08, 2009 4:31 pm Post subject: RE:Procedure Quiz1 may only be declared... |
|
|
do you notice how your original post had
and this new code does not?
(also there are no "end if"s) |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
hamid14
|
Posted: Fri Oct 09, 2009 10:44 am Post subject: Re: Procedure Quiz1 may only be declared... |
|
|
I know there are no end ifs, but thats not causing the problem is it? I put in end quiz1, because I thought your supposed to? o.o |
|
|
|
|
|
DemonWasp
|
Posted: Fri Oct 09, 2009 10:48 am Post subject: RE:Procedure Quiz1 may only be declared... |
|
|
Yes, that is absolutely causing the problem. Press F2 to indent your code and you should see something like:
code: |
procedure quiz1
if condition then
do some stuff
if condition2 then
do some other stuff
end quiz1
|
You must always include the end if, otherwise the contents of the if statement include everything after it in the file, including the "end procedure" which is incorrect. |
|
|
|
|
|
TheGuardian001
|
Posted: Fri Oct 09, 2009 4:18 pm Post subject: Re: Procedure Quiz1 may only be declared... |
|
|
But the lack of ends shouldn't be giving that specific error.
Unless that's not actually the entire code, it shouldn't be showing a procedure declaration error. |
|
|
|
|
|
DemonWasp
|
Posted: Sun Oct 11, 2009 4:14 pm Post subject: RE:Procedure Quiz1 may only be declared... |
|
|
Yes, the lack of ends should be giving exactly that error. The parser works linearly: it sees an if-start, then it sees a procedure-declaration and goes "that's not right", which is when it stops trying, because clearly your program is gibberish as far as it's concerned.
Turing does not support single-line if structures like C/C++/Java do. |
|
|
|
|
|
chopperdudes
|
Posted: Sun Oct 11, 2009 4:17 pm Post subject: RE:Procedure Quiz1 may only be declared... |
|
|
mayb i missed something, but if you look at his code, he never declared the procedure inside an if statement? and if you copy what he's posted and F1 it in turing, it actually doesn't give that error. |
|
|
|
|
|
andrew.
|
Posted: Sun Oct 11, 2009 5:39 pm Post subject: RE:Procedure Quiz1 may only be declared... |
|
|
Whatever the error is, the code is wrong. You must end an if statement with an "end if" in Turing no matter what. |
|
|
|
|
|
|