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.

Newcomers DBPro Corner / Problems with closing nests

Author
Message
zziggybear
9
Years of Service
User Offline
Joined: 30th May 2014
Location:
Posted: 30th May 2014 17:15
Hi there, I know this is probably a very obvious problem, but I'm not familiar with nesting in Darkbasic and I'm having trouble getting all the features of my code to function while nesting it all correctly.. I think I'm using the endif and loop statements incorrectly.

I'd really appreciate a quick pointer if anyone has a moment!

Thanks

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Jun 2014 01:55 Edited at: 1st Jun 2014 01:59
Indent your code better and make sure you're matching each control structure with the proper commands.

IF - ENDIF
DO - LOOP
WHILE - ENDWHILE
REPEAT - UNTIL

Every time you use one of these opening commands, everything inside of it should be indented until you close the control structure. Makes it much easier to read code and debug.

Which, it looks like you did. At first glance it was hard to tell because of the way you indented.


Unless you use a GOTO statement (which I advise you don't use), only your first block of DO-LOOP code will execute. And that wait key at the bottom doesn't do anything since nothing will ever escape any of the loops.

Here's a better way to manage code which has multiple components.


Login to post a reply

Server time is: 2024-04-18 08:18:04
Your offset time is: 2024-04-18 08:18:04