Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with the error- "Syntax error at 'End of File'. expected 'end if'"
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jonzey887




PostPosted: Sun May 04, 2014 4:32 pm   Post subject: Help with the error- "Syntax error at 'End of File'. expected 'end if'"

What is it you are trying to achieve?
A tic-tac-toe game with a mainmenu
What is the problem you are having?
when i try to run it, it tells me, Syntax error at 'End of File'. expected 'end if


Describe what you have tried to solve this problem
putting and taking away 'end if's


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


Turing:


%Hello World (x1,y1,x2,y2)
setscreen ("nocursor")   
 forward proc background
 forward proc mainmenu
    var y1:int:=25
    var y2:int:=375
    var title:int
    var options:int
    var xValue, yValue:int:=200
    var button:int:=0
    var instructionstitle:int
    var instructions:int
    options:=Font.New("Comicsans:20")
    title:=Font.New("Comicsans:50:underline")
    instructionstitle:=Font.New("Comicsans:35:underline")
    instructions:=Font.New("Comicsans:15")

%Play
proc Play
   background
    drawline(250,y1, 250, y2 , 48)
    drawline(400,y1, 400, y2, 48)
    drawline(125, 275, 525, 275, 48)
    drawline(125, 150, 525, 150, 48)

end Play
%pause program
proc pauseProgram
    var reply:string (1)
    getch (reply)
end pauseProgram

%background
body proc background
    drawfillbox(0, 0, 640, 480, black)
end background

%main menu
body proc mainmenu
  background   
   Font.Draw("Tic-Tac-Toe", 150, 325, title, 12)
   Font.Draw("Play", 300, 240, options, 14)
   Font.Draw("Instructions", 260, 160, options, 14)
   Font.Draw("Exit", 305, 75, options, 14)
   loop
   Mouse.Where(xValue, yValue, button)
   if xValue <= 260 and xValue >= 340 then
          if yValue <=280 and yValue >=200 then
                if button=1 then
                   delay(1000)
                   Play
                exit
end if
 
   drawbox(260,280,340,200,48)
  else
    drawbox(260,280,340,200,black)
end if
   if xValue <= 220 and xValue >= 300 then
          if yValue <=200 and yValue >=120 then
                if button=1 then
        drawfillbox(0,0,640,480,black)
        Font.Draw("Tic-Tac-Toe Instructions",70,300,instructionstitle,12)
        Font.Draw("Click in one of the 9 squares and a 'X' or 'O' will appear",0,250,instructions,14)
        Font.Draw("X always goes first",0,225,instructions,14)
        Font.Draw("First player to get 3 of their symbol in a row wins",0,200,instructions,14)
        Font.Draw("Programmed by Nathan Jones AKA JonzeyCoding",0, 100,instructions,14)
        Font.Draw("Press any key to continue",70,50,instructionstitle,12)
        pauseProgram
        mainmenu
end if



Please specify what version of Turing you are using
Turing 4.1.1a
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sun May 04, 2014 4:51 pm   Post subject: RE:Help with the error- "Syntax error at \'End of File\'. expected \'end if\'"

Every if statement needs an end-if. For example,

code:
if sky = blue then
    put "The sky is blue"
end if


You need to do this for every single if. The only exceptions are elsifs and elses- you only need one end if for all of the conditions associated with one if. For example,

code:
if sky = blue then
    put "The sky is blue"
elsif sky = white then
    put "The sky is white"
else
    put "I don't know what color the sky is"
end if
TWizard




PostPosted: Thu May 08, 2014 2:43 pm   Post subject: RE:Help with the error- "Syntax error at \'End of File\'. expected \'end if\'"

Your program is missing a few end if's. i spy near the bottom. How ever, insectoid is correct. The Turing language requires end's anywhere you put a beginning, this means. for's, if's, loop's, procedures, etc. Unlike python or some other languages.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: