Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Could not close nest!?!?!?

Author
Message
Marking_Dat
12
Years of Service
User Offline
Joined: 31st Jan 2014
Location:
Posted: 31st Jan 2014 17:23
Hello, im in a bit of a pickle here considering these are one of my projects due in 2 weeks. basically the process had been going smoothly until i got out of the basics and in to the professional part and i came in contact with the "Could not close nest" problem that i cannot get away from. please if you can help me please post a response, and here is my game.
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 31st Jan 2014 22:05 Edited at: 31st Jan 2014 22:07
The actual code is stored in the .dba file, not the .dbpro file, sorry
It might be easier though if you just copy all your code and post it as a code snippet(click on the 'code' button in the posting window, paste your code in, then click it again to close the code snippet block! Make sure your code is in between [ code ] and [ /code ]). It sounds like you've just forgotten an 'endif' or 'endfunction' somewhere in your code, or you haven't closed a loop... Simple to fix, don't worry
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 31st Jan 2014 23:18 Edited at: 31st Jan 2014 23:19
Quote: " It sounds like you've just forgotten an 'endif' or 'endfunction' somewhere in your code"


If I am not mistaken this would result in a "command out of place" error, and "could not close nest" only refers to loops (for, while, repeat or do-loop) that haven't been closed properly.

Usually these errors are relatively easy to find - with proper syntax indentation that is.
So just upload the actual code Marking_Dat and we should be able to solve the problem relatively quickly.

SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 1st Feb 2014 00:43
Quote: "If I am not mistaken this would result in a "command out of place" error"

Good point! I think endif and endfunction can trigger 'could not close nest' errors, but only if the compiler manages to get to the end of the code, and then finds the function or if-block still hasn't been closed
Marking_Dat
12
Years of Service
User Offline
Joined: 31st Jan 2014
Location:
Posted: 3rd Feb 2014 17:00
Here is the code snippet
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 3rd Feb 2014 23:25 Edited at: 3rd Feb 2014 23:27
Found the problem! At the start of the main loop for Level 5, you accidentally put the start of the loop twice:

center text 320,160,"How many oceans are there in the world?"
center text 300,280,"A: 4"
center text 300,300,"B: 5"
center text 300,320,"C: 14"
center text 300,340,"D: 5"
wait key
repeat
Elapsed=(Timer()-T)/1000
TimeLeft=seconds-elapsed
text 20,20,"Seconds Left: "+Str$(TimeLeft)

repeat
Elapsed=(Timer()-T)/1000
TimeLeft=seconds-elapsed
text 20,20,"Seconds Left: "+Str$(TimeLeft)


That meant there was the start of an extra repeat loop in your code, but no until to finish it, so it couldn't close the end of the program properly. Anyway, here's the code without that bit in:


Good luck with your game!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Feb 2014 15:57
In the future, indent your code and you won't run into errors like this. Or even if you do you should be able to quickly find them.

Marking_Dat
12
Years of Service
User Offline
Joined: 31st Jan 2014
Location:
Posted: 4th Feb 2014 17:22
thanks!

Login to post a reply

Server time is: 2026-07-07 19:09:41
Your offset time is: 2026-07-07 19:09:41