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.

DLL Talk / Static variables

Author
Message
Epimetheus
21
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Naples, Florida
Posted: 11th Jan 2006 21:09
Would it be possible to make a static variable DLL to plug into darkbasic? So I could have variables that retain their values after being called. Now I know you can do it with globals, but static variables are private and less messy.

So is it possible? I think I may try to make a DLL for this if it is.
Zedane
20
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 11th Jan 2006 21:55
it should be possible,
user calls a function(variable), stores the variable untill later called. Thats a simple DLL, but if you have use for it, it seems plausable to make.


around here.. normal's just a setting on a hair dryer
Epimetheus
21
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Naples, Florida
Posted: 13th Jan 2006 21:09 Edited at: 13th Jan 2006 21:10
Hmm, but how would you make it so the string in the function parameter would be made into a variable that you could refer to?

Basically how do you make a string into a variables's name, e.g.

string var_name="var_1";
integer var_name;

any ideas, I get a compile error when doing this.
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 13th Jan 2006 21:17
I don't think you can do it implicitly under C.

If you want a string keyed array (basically what you want) then

- if you want it definately in a DLL then you'll have to look up ways of getting string keyed arrays or collections in C. A C guru will need to give you more definate details there.

- it can be done in DBPro using your own hashing method (make a number from the word somehow and store it in in an array using that number as an index)

- using a scripting plugin like Unity you can store bits of data alongside numbers with relative ease.

Epimetheus
21
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Naples, Florida
Posted: 14th Jan 2006 00:02 Edited at: 14th Jan 2006 00:02
LOL, don't worry I already bought your plugin, awsome job by the way


anyway, mabye it's possible to have an array of structures or something that references it so in Darkbasic you would type:

make_static("var_1")

int_var=get static("var_1")


think this could be simply implimented?
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 14th Jan 2006 00:42
Quote: "anyway, mabye it's possible to have an array of structures or something that references it so in Darkbasic you would type:

make_static("var_1")

int_var=get static("var_1")


think this could be simply implimented? "


Using Unity, yes



And probably possible with C too, with some appropriate coding. I'm only an expert with Unity really

Epimetheus
21
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Naples, Florida
Posted: 14th Jan 2006 06:09 Edited at: 14th Jan 2006 06:10
Wow thanks!

I'm still going to try a to make a more intergrated solution in c++, but this will do nicely for the time being!
Epimetheus
21
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Naples, Florida
Posted: 14th Jan 2006 06:17 Edited at: 14th Jan 2006 06:31
Excellent method!




Heres a little demo for the people with unity




By the way, is there any speed loss with ths compared to a global or a variable that would be in a dll?

if there is it's probably neglegible except for crucial functions though I think.

The only problem I can see in this method is that the variables inside are not private(or are they?), so you could not for instance have a variable like playerhealth in one function and have another playerhealth in a second function and have them unique from each other.
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 14th Jan 2006 11:11 Edited at: 14th Jan 2006 11:11
Quote: "By the way, is there any speed loss with ths compared to a global or a variable that would be in a dll?

if there is it's probably neglegible except for crucial functions though I think. "


I imagine there would be a negligible difference as al the function calls are involved.

imo the best bit about that way is that you can get bits of data under a key held in a string, so at run time the key can change as much as you want

Login to post a reply

Server time is: 2024-11-21 23:24:03
Your offset time is: 2024-11-21 23:24:03