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 / Alright, you guys are probably gonna laugh at me...

Author
Message
flibX0r
23
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Western Australia
Posted: 10th May 2003 08:26 Edited at: 10th May 2003 09:04
Laugh if you want.
I can understand everything in DBPro. If i read through the help files i can figure out almost everything. But there is a catch.

The help files do not explain how to make global variables. So far i haven't figured it out so i have posted on here.

P.S. If anyone has been reading about our project "Children of Sivara", we should have a promo video up and online very soon (like today).

Thnx in advance

"But we couldn't do that Mr Flibble," questioned Rimmer. "Who'd clean up the mess?"
--Twin P4 Xeon 2.0 Ghz, GeForce Quadro4 XGL 128MB, 1Gb DDR RAM, 19" Flat Screen--
Neophyte
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 10th May 2003 08:34
"The help files do not explain how to make global variables."

All variables declared outside of a function are global. So simply declaring A=45 would make the variable A global and set its value to 45. Nothing to it.

flibX0r
23
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Western Australia
Posted: 10th May 2003 08:42
Oh, thats easy. Thnx. Don't know why i didn't think of that my self. I do programming in C/C++ and its the same way you do it in that.

"But we couldn't do that Mr Flibble," questioned Rimmer. "Who'd clean up the mess?"
--Twin P4 Xeon 2.0 Ghz, GeForce Quadro4 XGL 128MB, 1Gb DDR RAM, 19" Flat Screen--
flibX0r
23
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Western Australia
Posted: 10th May 2003 09:42
Neophyte: You lied!!! They don't become global!!! Come on people. I know there is the command global, but i don't know how to use it.

Please help me! my code is getting unreadable!!!

"But we couldn't do that Mr Flibble," questioned Rimmer. "Who'd clean up the mess?"
--Twin P4 Xeon 2.0 Ghz, GeForce Quadro4 XGL 128MB, 1Gb DDR RAM, 19" Flat Screen--
iac249
23
Years of Service
User Offline
Joined: 26th Mar 2003
Location: USA
Posted: 10th May 2003 10:04
Try:
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 10th May 2003 10:10
an array declared at the top of your main is global

other variables need what Spag. suggested

flibX0r
23
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Western Australia
Posted: 10th May 2003 10:27
That works, thnx.

Now my arse is no longer on the line, for the time being

"But we couldn't do that Mr Flibble," questioned Rimmer. "Who'd clean up the mess?"
--Twin P4 Xeon 2.0 Ghz, GeForce Quadro4 XGL 128MB, 1Gb DDR RAM, 19" Flat Screen--
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 10th May 2003 10:30
hehe we all gotta be noobs at one point, no harm done

Puffy
23
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United States
Posted: 10th May 2003 10:40
o_O Yes even indi was a n00b once... me on the otherhand... nope...

AMD Athlon XP 2100+ OC to 3Ghz/1.5gigs ram/128mb ti4200/120gigs hd/19" monitor/Sound Blaster Audigy Platinum EX/3072kbs Sat Con... I joined in!
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 10th May 2003 10:42
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 10th May 2003 11:35
Never!

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_101.zip
Puffy
23
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United States
Posted: 10th May 2003 17:14
^_^ Lets just say I ate a tuna sandwitch from a gas station yesturday and feel like dieing...

AMD Athlon XP 2100+ OC to 3Ghz/1.5gigs ram/128mb ti4200/120gigs hd/19" monitor/Sound Blaster Audigy Platinum EX/3072kbs Sat Con... I joined in!
Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 10th May 2003 19:21
HAHAHAHAHAHAHA!

Sorry, you SAID I could laugh

I can't remember DarthPuff or indi ever being a n00b .

Personally I'm still getting used to this 'as' thing . Still have a habit of just making up variables on the fly with mathematical operations...

--Mouse

Famous Fighting Furball
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 10th May 2003 22:15
Bah - they're both noobs until they actually release something! *taps fingers waiting*

Pneumatic Dryll
Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 10th May 2003 22:19
Dwarven Tales is the most promising in-progress DB project I've seen (with Dark Konflict coming up close behind)... indi ain't no n00b .

--Mouse

Famous Fighting Furball
Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 10th May 2003 22:20
Make that 'one of two contestants for most promising project' since I'm dying to play RiftSpace too .

--Mouse

Famous Fighting Furball
Neophyte
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 11th May 2003 00:08
@Mr. Fibble

"Neophyte: You lied!!! They don't become global!!! "

Yes, they do. When you declare a variable outside of a function they are global. Take these code snippets for example:


The variable A is declared as 45 and the subroutine PrintA prints the variable A.

I think the confusion arised when you try to use a funcition to access the variable without passing it to it first.


This will print 0 and not 45. Also, variables declared inside a function will be local.

This too will print 0 and not 45. I hope this cleared up what I meant.

Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 11th May 2003 00:56
I think he meant that he couldn't see them in the IDE's variable list.

--Mouse

Famous Fighting Furball
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 11th May 2003 01:23
another way to set global variables is just stick word 'global' in front,

where you have:

a=1
b=2

change to:

global a=1
global b=2

Gronda, Gronda
Kentaree
23
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 11th May 2003 01:32
@Neophyte: I think the point of making a variable global is being able to use them in functions, gosubs are technically just jumps in your program, not like procedures/whatever, so its straightforward they can just be used in every non-function part of the program.

Whatever I did I didn't do it!
flibX0r
23
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Western Australia
Posted: 11th May 2003 07:30 Edited at: 11th May 2003 07:51
I agree with Kentaree. Gosubs arn't functions, thuis the variable aren't global. But i know ow to do it know thnx to Spagyrist.

Another question though. To make it easier to use the interface in our game, i have simulated the RECT type that i in c/c++, then given it a value and forwarded it to a function like so:



But when i compile it, it says: "#100038: Could not find field 'x1' in type 'RECT' at line whatever"

What the hell is going on???

"But we couldn't do that Mr Flibble," questioned Rimmer. "Who'd clean up the mess?"
--Twin P4 Xeon 2.0 Ghz, GeForce Quadro4 XGL 128MB, 1Gb DDR RAM, 19" Flat Screen--
Neophyte
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 11th May 2003 10:23
@Mr. Flibble

"Gosubs arn't functions, thuis the variable aren't global."

I never said gosubs were functions. My point was almost everything can access a variable if it is declared outside of a function. Besides if you want to access a variable through a function just pass it to it like this:


Anyway, as to your other problem.

"To make it easier to use the interface in our game, i have simulated the RECT type that i in c/c++, then given it a value and forwarded it to a function like so:



I'm not too sure what your problem is exactly as I would need to see more code, but I have found one error that stood out:



If your are trying to return your variable Over your going to have to set your function up like this:


You can't return a variable from a function unless you set the function call to a variable. I know this isn't documented in the help files but a lot isn't documented in the help files and I thought I would give you a leg up here and point this out because I've run into this problem before myself. And as a side note, may I recommend the DBPro Online Glossary. It is better than the help manaul sometimes and helped me solve that function problem. You can find it here at :
http://www.realgametools.net/glossary/index.php3?theme=1&level=2&document_id_select=3

I hope this information will be of some use to you.

flibX0r
23
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Western Australia
Posted: 11th May 2003 10:41
I figured it out anyway. i only works if i put the type declaration at the VERY top of my source code.

Neophyte: What the hell are you on about???

"almost everything can access a variable if it is declared outside of a function"

Except functions! It don't work! yo need to use global varname as integer



Your change to my is just crap. My way of doing it is the proper way. You are babbling on about crap.

If you will notice my code says this:



I do set the function call to a variable. You don't put the variable where you put it though cos i doesn't do anything.

"But we couldn't do that Mr Flibble," questioned Rimmer. "Who'd clean up the mess?"
--Twin P4 Xeon 2.0 Ghz, GeForce Quadro4 XGL 128MB, 1Gb DDR RAM, 19" Flat Screen--
Neophyte
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 12th May 2003 07:06 Edited at: 12th May 2003 07:07
@Mr_Flibble

"I figured it out anyway. i only works if i put the type declaration at the VERY top of my source code."

:-s

""almost everything can access a variable if it is declared outside of a function"

Except functions! It don't work! yo need to use global varname as integer"

Yes it does work. You just need to pass the variable you are using in as an function argument. Using the global command can get you around that problem but it is a bad way of going about things because that now exposes that variable to your entire program to modification which will be hell on debugging. What possible situation have you come across were passing in it in is not an option?

"Your change to my is just crap. My way of doing it is the proper way. You are babbling on about crap."

Your rudeness aside, I was mistaken about the returning a variable example. When I said this:


I meant this:



It was 2:30 in the morning and my mind was a little hazy. I apologize for the bad example as I thought you were making the same mistake I just got through with and wished to help you to avoid it but it appears you don't need my help with that after all.

Mnemonix
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 15th May 2003 01:14
How many things can be said about global variables.

Where did his Ak-47 go.
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 15th May 2003 01:29
well you could say

global variables

is an anagram of

large saliva blob

Gronda, Gronda
Mnemonix
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 15th May 2003 01:38
Thanks for that u daft hedgehog

Where did his Ak-47 go.
CloseToPerfect
23
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 15th May 2003 05:09
just want to add that types and arrays are global by default. I guess you it would be bad programming to use them since "that now exposes that variable to your entire program to modification which will be hell on debugging.", calm down just a joke,haha

but Neophyte has a good point, if you declare a varible global and then use the same varible ID as a local in a function it will give you fits debugging!

CTP
flibX0r
23
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Western Australia
Posted: 17th May 2003 10:31
@Neophyte:

Sorry for the rudeness, but i had a programming milestone and had to get some stuff done.

Yes, your wy works to pass the variables. But i needed to store more than variable and can't do that by returning something.

"But we couldn't do that Mr Flibble," questioned Rimmer. "Who'd clean up the mess?"
--Twin P4 Xeon 2.0 Ghz, GeForce Quadro4 XGL 128MB, 1Gb DDR RAM, 19" Flat Screen--

Login to post a reply

Server time is: 2026-07-11 07:05:53
Your offset time is: 2026-07-11 07:05:53