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 Discussion / Global / Local / #Constant, etc.

Author
Message
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th May 2007 15:24
I just wrote a presentation for a school project in DBP.
The thing is that the computers at my school of course have inferior DX versions; however, they seems to be able to run DX7.
Therefore, I figured that I could rewrite the source in DBC; shouldn't need to be changed that much.

Now though, apparently there are no such things as global variables, constants etc. in DBC.
How the heck to go around that?
I don't really feel like making every global variable an array :/

Suggestions, please

"I kören hörs de brummande busarna Björnligan och Gondolen"
Satchmo
21
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 9th May 2007 15:32 Edited at: 9th May 2007 15:34
I think tdk has some tuts on that, like he does for everything.
Give me a while since theres a few of them but im sure I could find it.

[edit]
here it is

http://forum.thegamecreators.com/?m=forum_view&t=96075&b=7

MadrMan
20
Years of Service
User Offline
Joined: 17th Dec 2005
Location: 0x5AB63C
Posted: 9th May 2007 16:07
It describes there how to use arrays instead of globals, because there are no globals.

Quote: "
I don't really feel like making every global variable an array :/
"


So that doesn't help him. I think however it might be the only way.
Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 9th May 2007 16:13
In DBC you should be using subroutines where you can, instead of functions.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th May 2007 19:36
Quote: "In DBC you should be using subroutines where you can, instead of functions."


That will get around the global variable problem, but with the Search and Replace feature in the IDE, you could fairly quickly replace the variables names.

Just replace all occurences of 'VariableName' with VariableName(0) then add a DIM VariableName(0) at the start of the program. Just repeat with all the vars you need to be global.

As you have functions in DBC, there's no obvious reason to change all the functions to subroutines as many should work just fine.

This might actually be a bit quicker than converting all the functions to procedures...

TDK_Man

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th May 2007 16:35 Edited at: 11th May 2007 16:35
Quote: "As you have functions in DBC, there's no obvious reason to change all the functions to subroutines as many should work just fine"

Unless you don't want to be doing a hack, which I think using single item arrays is. In BASIC it's always been proper to use subroutines when you want to share the use of variables in multiple procedures and the main loop itself. The only reason most of us use mainly functions in DBP for main procedures now is because we have the global keyword.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 11th May 2007 17:11
@TDK: Yeah, I did that.
Unfortunately, it fell when it occurres to me that DBC doesn't support alpha blending on sprites; I managed to convince the staff to temporarily install DX9.0c for my presentation though

"I kören hörs de brummande busarna Björnligan och Gondolen"
RUCCUS
21
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 12th May 2007 06:04
Rudolpho, just do a google search for "Alienware Dark Basic Trial". The trial version released for the alienware competition still has a download page on TGC's site. IIRC the DX version is 7, so it might run.

Login to post a reply

Server time is: 2026-07-05 18:37:55
Your offset time is: 2026-07-05 18:37:55