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 variables, arrays, etc... in dark edit?

Author
Message
PoHa!84
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 3rd Oct 2003 22:43
The name says it all. I have read somewhere that DarkEdit has the ability to make a global variable/array. If I remember right then that means that the variable/array can be recognized by any function. Is this right, or did I read wrong? Also, how would I declare it in dark edit. DarkEdit highlights the word "global" as if it were keyword, but its not in the help file. Thanks for any help.

Destroy you with my mind, I could!
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 3rd Oct 2003 23:15
The way DarkEdit's global variables work is just to declare a 1 dimensional array that can hold one value, as arrays are global in DB. So if you want to make a global variable called glob, you'd use:

dim glob(1)

and you would be able to access it from any function, considering it was declared outside of a function.

Cheers,
Kentaree

I would be unstoppable if I could just get started...
PoHa!84
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 3rd Oct 2003 23:27
Okay, so, arrays are always global then. I got it...
Thanks Kentaree!

Destroy you with my mind, I could!
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 4th Oct 2003 00:27
No problem, glad to be of help to you

Cheers,
Kentaree

I would be unstoppable if I could just get started...
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 4th Oct 2003 09:57
OK, but what if you change the value of that array (glob(1)) inside of a function... is that new value accessable outside of the function? or does it only aply inside the function?

Thanks For Your Help...

If Quizz's Are Quizzical, Then What Are Test's?
Check my profile for a quick test of knowladge...
PoHa!84
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 6th Oct 2003 17:40
He brings up a good point, Kentaree! Teach us, oh wise and powerful one!

Destroy you with my mind, I could!
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 6th Oct 2003 18:22
Yes, values assigned in a function to an array are useable then outside of the function, as a global variable is a single memory location which holds a value (or values in this case), and can be reffered to anywhere.

Cheers,
Kentaree

I would be unstoppable if I could just get started...
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 6th Oct 2003 18:51
Ah, thank you...

You Helped...

If Quizz's Are Quizzical, Then What Are Test's?
Check my profile for a quick test of knowladge...
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 6th Oct 2003 18:53
No problem

I would be unstoppable if I could just get started...
PoHa!84
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 6th Oct 2003 19:12
All hail the mighty Kentaree! Or...not. Whichever you prefer...
Thanks again Kentaree!

Destroy you with my mind, I could!

Login to post a reply

Server time is: 2025-05-20 14:13:33
Your offset time is: 2025-05-20 14:13:33