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 Discussion / Nesting Error?

Author
Message
gh0u1
21
Years of Service
User Offline
Joined: 24th Apr 2004
Location:
Posted: 26th Apr 2004 23:09
An add-on from an earlier post. I don't know quite what I'm doing wrong, but I'm getting this nesting error that I can't for the life of me identify. I'm sure it's something minute like a misuse of gosubs or an 'endif' in the wrong place, but it's close to the only thing that's hindering me from finishing this. Any help will be greatly appreciated, and I'll be willing to include you in the credits, though I doubt this program will get very popular. Thanks, all!
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 26th Apr 2004 23:13
Ive found one:



Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
gh0u1
21
Years of Service
User Offline
Joined: 24th Apr 2004
Location:
Posted: 26th Apr 2004 23:38
GOOD GOD.

Not only that one, but the following bit lacked ENDIFs completely. And now I feel like an idiot. Thanks, man!

Mock my blunder!
gh0u1
21
Years of Service
User Offline
Joined: 24th Apr 2004
Location:
Posted: 27th Apr 2004 00:15
Ugh. Okay. So I fixed that, and now the game runs pretty well, EXCEPT when it gets to the 'estats' subroutine. There's a stack overflow on line 204, and that's it. Anyone know how to deal with this?
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Apr 2004 22:44 Edited at: 28th Apr 2004 22:47
I shortened the "estats" sub routine, and reorganized "stats" so I could read more clearly whats going on. If I had to guess, I'd say it's due to a missing return statement in "stats". Without a return statement at the end, its possible that one is never reached because of the IF statements. Technically, the program would continue right on into "estats", but I'm unsure of whether that would give errors or not. I know java wouldn't let you get away with it.

estats:



stats:



Also, take a look at "estats". Suppose "rep" equals zero as the subroutine is called. You subtract 1 from it, resulting in -1. It hits the IF ELSE statement at the bottom, and recalls "estats" again. This time, "rep" will be -2. See the pattern? You'll be infinitately stuck inside the subroutine, which if called too many times results in a stack overflow error.

"eureka" - Archimedes

Login to post a reply

Server time is: 2025-05-23 12:26:07
Your offset time is: 2025-05-23 12:26:07