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.

2D All the way! / Gosub/return

Author
Message
Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 2nd Apr 2004 11:21
I understand the idea of subroutines, but Im a little confused about how to use them, and I cant seem to find the right documentation about them. In my program I write

gosub blahblah

then I have "blahblah" as a heading and the program jumps to there, and when it reaches "return" it goes back to the "gosub" command. My question is this: how do I say to DarkBasic that "blahblah" is a flag? Do I have to put it in capitals, or have a semicolon with it or something?

Please would somone also explain how functioins work, and how they are different from a gosub command.

Any help here would be great!

GIve me more power!
the_winch
22
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 2nd Apr 2004 13:42 Edited at: 2nd Apr 2004 13:46
to define a subrouting you need a label like when you use goto.
from the dbpro help
Quote: "The label can be made up from any combination of alphabetic characters, but you must end the declaration of the label using a colon ":". You only need to use a colon when you are declaring the label, and should not be used when calling the label from a GOSUB command."


So basically a label is any combination of letters and numbers that ends in a ":".



Functions are quite well explained in Hamish McHaggis tutorial that you can download from here.
Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 2nd Apr 2004 16:30
Thank you MrWinch

GIve me more power!

Login to post a reply

Server time is: 2025-08-09 02:12:47
Your offset time is: 2025-08-09 02:12:47