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 / functions & subs

Author
Message
Bren
22
Years of Service
User Offline
Joined: 15th Oct 2003
Location: Belgium
Posted: 20th Oct 2003 00:32
I don't like to use gosub so I only use functions, it keeps my code more readable for me. I also use the blue IDE editor so I'm working with multiple files. The thing is I want to have "public" variables, meaning I want 1 file with for example all the objects declared + their number assigned.

Then I want to be able to use these variables in all my functions spread over all the other files in the project.

Now for some reason this isn't working, is this because I'm using functions instead of sub's or?

This is probably a stupid Q, but I'm new to DB

Games don't kill ...
I do!
http://www.gamingzone.be the ultimate gaming community
adr
23
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 20th Oct 2003 02:05
I do a very similar thing ..

I have a file called globals.dba and in there are all my object offset numbers, counters, limits, ingame options etc ..



At the very start of my main file (the first one created) I just have a set of gosubs. I too prefer the look of functions to gosubs, but I think gosubs suit global definitions better...



Hope this helps

Can I ask you a Question?
What is it?
It's an interrogative form of sentence, used to test knowledge. But that's not important right now.
Bren
22
Years of Service
User Offline
Joined: 15th Oct 2003
Location: Belgium
Posted: 20th Oct 2003 03:22
thanks alot adr

Games don't kill ...
I do!
http://www.gamingzone.be the ultimate gaming community
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 20th Oct 2003 05:56
Basically you just need to use the GLOBAL keyword. This applies to arrays as well as other variables.

Login to post a reply

Server time is: 2026-07-26 09:30:34
Your offset time is: 2026-07-26 09:30:34