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 / the Return function

Author
Message
LiVe
23
Years of Service
User Offline
Joined: 5th May 2003
Location:
Posted: 17th May 2003 02:35
could someone take a look at this code and tell me why it gives me a parameter mismatch error?

RETURN spacepress=SPACEKEY()

thnx alot!
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 17th May 2003 03:33
Quote: "RETURN
You can use the RETURN command to return to the program location of the last jump performed. In order
to use the GOSUB command you must create a subroutine in your program that terminates with the
RETURN command. To create a subroutine you must write a label in your program followed by a sequence
of commands. 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.
"


What is it you are trying to achieve LiVe?

I hear and I forget. I see and I remember. I do and I understand.
Mnemonix
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 17th May 2003 04:25
Some people prefe to use gosubs rather than Functions. I at the moment am undecided. Gosubs allow you to use global variables easier(all are global) and the changes it makes to variables will apply program wide. Functions do not do this (except arrays) and therefore are safer. Functions for bigger applications (like Eternal Destiny) but gosubs are ok for smaller applications such as a pac man rip off (atari will have ur head)

Where did his Ak-47 go.
The Wendigo
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 17th May 2003 05:56
Gosubs are old in my opinion. It's all about functions. Gosubs for the old BASIC language if you ask me. I've heard you should always try to avoid using global variables if you can and that's what I do. Still, it's your preference.

Current Projects: mini BSP maker 50%, Height Mapper with many features 75%, FPS/RTT Nameless at the moment 15%
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 17th May 2003 06:36 Edited at: 17th May 2003 06:42
I use alot of both...

Gosubs are better for long code that uses many variables, or does something like load objects, settings, etc.

Functions, on the other hand, are better for shorter code that will be called many times and uses few variables.

So, In my opinion, a little of each is best. Just be sure to keep your functions at the BOTTOM of your code, or any code underneath it will not be run.

I seperate mine with "Rem *****************'s"



It may seem a bit noobish (no offense), but it helps me keep organized (somewhat). If only my room was this neat, eh?

Food is güd!
"All programmers are playwrites and all computers are lousy actors" -Anon
Click Here!!!

Login to post a reply

Server time is: 2026-07-11 12:02:23
Your offset time is: 2026-07-11 12:02:23