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

Username:   Password: 
 RegisterRegister   
 Duplicate end if, and program is stuck in a loop at a spesific area
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Stickman




PostPosted: Tue Jun 14, 2022 2:56 pm   Post subject: Duplicate end if, and program is stuck in a loop at a spesific area

What is it you are trying to achieve?
Im trying to make a lemonade stand game for my final assignment, if i don't hand finish the 2nd part of my assignment then my mark is going below 52


What is the problem you are having?
Everytime the procedure Sell is run and the construction event = true and weather = rain or thunder then the program freeze the menu only, and it cause the program need multiple end if.


Describe what you have tried to solve this problem
i tried to place an end if where there's a duplicate that doesn't have an end if but it made it worse, I tried to copy and paste the code from 1 part to another but that didn't work, this works without the graphic but the assignment says I need to add graphic to the game.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Due to the code being too long I have attached the coding

What version of turning are you using
Recent version (4.1.1)



lemonade stand (1).t
 Description:

Download
 Filename:  lemonade stand (1).t
 Filesize:  12.2 KB
 Downloaded:  68 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Stickman




PostPosted: Fri Jun 17, 2022 8:24 pm   Post subject: RE:Duplicate end if, and program is stuck in a loop at a spesific area

My project is due on Friday
Stickman




PostPosted: Wed Jun 22, 2022 8:33 am   Post subject: RE:Duplicate end if, and program is stuck in a loop at a spesific area

I have 2 days left now to hand that in, I am close to failing my class cause of this issue and I fail this class then i have to go to summer school
SNIPERDUDE




PostPosted: Thu Jun 23, 2022 9:09 am   Post subject: Re: Duplicate end if, and program is stuck in a loop at a spesific area

Firstly, debugging these types of issues are much easier when using indentation for "blocks" of code that are part of if statements, loops, or procedures.

i.e.
Turing:
procedure my_proc
    if condition then
        do stuff
        do more stuff
       
        loop
            if potato then
                do this
           
            elsif spud then
                do that
           
            end if
        end loop
    end if
end my_proc


Adding some space between procedures helps makes reading one's code easier too. I use a couple blank lines between, but even one gets the job done.

After spacing out your code so I can read the flow of it I found a place that might be responsible,
I found perhaps a couple too many end ifs at the end of your sell procedure.
I haven't run your code but I'm sure it's this or a similar issue.

Hope this helps, and best of luck mate

EDIT:
Had the wrong section at fault in my answer. The point about using indentation (via tabs or spaces, usually 4 per tabbing) stands.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: