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 / Issues with goto's

Author
Message
Steve J
18
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Vancouver, Washington
Posted: 14th May 2006 19:59
WHenever I try and use a goto to go back to a previous setting, it silent crashes... Source:




Attached is complete media...

Evil Mods keep erasing my below 600x120 sig...

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th May 2006 20:20 Edited at: 14th May 2006 20:21
I know you probably don't want to hear this, but the source code is a good example of why you shouldn't use GOTO. The moment you GOTO another part of the code, you lose all consistency and ability to work out what the hell is going on.

It is much better practise to use GOSUB's, or many people like myself use functions which is easier still to understand.

The biggest issue is thatyou have do/loop constructs that are prematurely ended. You should never jump out of a loop with a goto, because it totally throws the program stack into disarray, and is probably what's causing the problem.



Steve J
18
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Vancouver, Washington
Posted: 14th May 2006 20:36
I dont mind the method used, and I would love to learn something that could help keep my program neat, but I tried gosubs, but the issue is that the images (buttons) from the other buttons are still there in the gosub, and for the life of me, I cant figure out how to stop it:/.

And can you show some samples of using a function..? It sounds like an intresting thing to do, and I know that it would be pwntasticly easy to keep my code from dribbling about.

Evil Mods keep erasing my below 600x120 sig...
Steve J
18
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Vancouver, Washington
Posted: 14th May 2006 21:16
Ok, I fixed the gosub thing, but now when I click back to return, it doesnt return, just silent night crash...


and...


Evil Mods keep erasing my below 600x120 sig...
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 14th May 2006 21:57
Sorry, but you are still completely on the wrong track and Return should never be used like that.

These are the very basic building steps of programming and are much easier to learn by reading some of the many tutorials available.

Take a look at the tutorials for beginners on my web site. They will show you a basic layout for programs, including where Do..Loop is used as well as how to use procedures and functions.

(Link below).

TDK_Man

Steve J
18
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Vancouver, Washington
Posted: 14th May 2006 22:16 Edited at: 14th May 2006 22:32
I just started this version (a rewrite), and my old code was much longer:


I have just been away from darkbasic pro for a long time..

edit: Thanks for the help TDK, after 10 minutes the code is looking nicer, and I have gotten rid of the goto command...completely.

Evil Mods keep erasing my below 600x120 sig...
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 15th May 2006 01:56
congrats

Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 15th May 2006 16:15 Edited at: 15th May 2006 16:17
Thats much better then your first code. You seem to learn very fast.

EDIT:

Now I notice the part about that you havent used darkbasic in a while, but you used it before. But still, the point is the same.

Login to post a reply

Server time is: 2024-11-26 21:31:28
Your offset time is: 2024-11-26 21:31:28