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 / Can not close nest

Author
Message
Purplepickle
15
Years of Service
User Offline
Joined: 4th Jun 2011
Location: Between hopeless and needs improvement..
Posted: 2nd May 2012 00:06
Hey everybody I finally got how to use DBP and I haven't been on in a while. I was working on this text adventure and I got a "Can't close nest at line (last line#)"

I can't figure it out, I know what the error is but I can't find it. Take anything you want from it but if you can see if you can find the error.


Yeah, I know I hate doing this I looked over the whole thing six times and I can't find it.

Wait, what?
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd May 2012 00:18
You would help yourself and those who might wish to help you if you indented your code sensibly. That's 500 lines of code and it's very hard to see its structure.

For example, things like this



would be much easier to read, understand and check if indented something like this



As you can see I haven't finished indenting but you should be able see where all the nests are when you've finished the task. Then you'll probably see the missing one immediately.
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 2nd May 2012 01:54
What Green said. You really need more structure. I would recommend not using gotos at all. Gotos are almost always a sign of bad code structure. Also functions are neater than gosubs, even if they don't take any arguments.

One guess at your problem though is below. I didn't check any further to see if this is correct, but from the pattern of the code in that area, it looks like the marked ENDIF should match the previous IF, but won't because the previous IF is completed by the THEN statement. An extra ENDIF would cause the "cannot close nest" problem.



mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 2nd May 2012 20:39 Edited at: 2nd May 2012 20:40
Here you go:
92 IF's
57 then's
34 endif's

you missed one IF ! I can't tell where it must be placed - it's your game after all.

«It's the Shader, shader me this, shader me that»
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd May 2012 20:43
Well spotted!

Login to post a reply

Server time is: 2026-07-08 08:53:15
Your offset time is: 2026-07-08 08:53:15