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 / CONTINUE command?

Author
Message
EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 31st Mar 2003 09:29 Edited at: 31st Mar 2003 10:45
In many languages, you can skip to next iteration of the loop with a "continue" statement. In C it looks like:



(code got chopped on the original posting)

MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 31st Mar 2003 10:11 Edited at: 31st Mar 2003 10:11
Not quite, it looks like :



In DBPro, you can either adjust the variable in the FOR/NEXT,WHILE,REPEAT loops or use a (yuk) goto command to skip commands, ie:



Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 31st Mar 2003 10:48
Take a look again... the code got chopped.

Still can't think of any way to avoid some statements in the loop?

The only think I could come up with was something like this:



Yuk.

MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 31st Mar 2003 13:50
Good use of the Edit button there...

As I said, you could either increase the variable yourself and skip around code, or use a goto command... The choice is yours..

Might be worth sending an e-mail requesting this command...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Attreid
23
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 31st Mar 2003 20:02
there's the command exit for the loops in db


it doesn't exit the programm but the loop

Bu$herie
How many civilians is he going to kill ? I know that Bush will sit at God's left, next to Saddam.
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 31st Mar 2003 21:42
Which is not what Mr Ed wants...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 31st Mar 2003 21:49 Edited at: 31st Mar 2003 21:50
Right... "EXIT" is very handy... took me a while to find it last night, but short-circuiting loops is what I'm really looking for. Oh well, I'm not going to request any new features yet... I don't want to detract DBS from fixing the SAB (stupid ATI bug).

Thanks for the help guys!

spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 31st Mar 2003 23:45
Another thing that other languages allow is to specify how many loops to exit. So if you are 5 loops in, you can bomb out completely without a lot of faffing around.

Gronda, Gronda
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Apr 2003 01:35
The continue command would make a great addition - Personally, I use it all the time.

Exiting several levels of a loop would be error prone.



If you need to do this, you can break all the 'rules' and use a goto to get out of the loop, or put the loops inside a function or subroutine and exitfunction/return.
swdave
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United States
Posted: 2nd Apr 2003 08:36
Its handy to set the loop counter.

for i=1 to 10
for j=1 to 10
for k=1 to 2
k=2:j=10:i=10
next k
next j
next i

Login to post a reply

Server time is: 2026-07-23 02:37:00
Your offset time is: 2026-07-23 02:37:00