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.

Newcomers DBPro Corner / Please explain #cont global and type usage/functionallity

Author
Message
Revolution
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location:
Posted: 28th Feb 2007 13:17
I used DB before it went pro years ago, im now using pro and i dont know what #Const Global or Type do nor can i find any explaination about them, but i keep seeing them everywhere.
Please could some one explain
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Feb 2007 17:00 Edited at: 28th Feb 2007 17:00
Check out this for Types:
http://forum.thegamecreators.com/?m=forum_view&t=55858&b=1

Globals are variables that can be access throughout the program including funtions. Everything in a function is local meaning it's seperated from the main program. An example:



In the function you can see the "print i". i should print 1234, but because a function is seprate, i equals nothing(0). You could input i into the function like so:



Using a global will let the function access the variable i as so:



For #constants I would like to quote Scraggle.
Quote: "
A #Constant is the opposite of a variable.
Like a variable it too can hold a value but unlike a variable it's value is constant.
Sounds pretty pointless right?

Well, not really. I find they come in very handy when writing your code because they tidy things up a little.
For example: If I have a complex equation that I struggle to remember and can't be bothered typing each time I use it, then I could declare it as a #constant (have a look at 'c' in the code) or maybe I just want to replace values with words to make it make it easier to remember what they are doing. (Black & White in the code)
"


An here the example:


Hope this helps.
wildbill
18
Years of Service
User Offline
Joined: 14th Apr 2006
Location:
Posted: 28th Feb 2007 17:00
The #constant command makes constances.
example:
#constance TILEWIDTH = 32, would in insure the variable TILEWIDTH would be worth 32 anywhere in the program.

Global makes the variable available anywhere in the program, but is not a constant ie... it can be changed as needed.

Type is a user defined type.
example:

Type unit
name$
x,y
endtype

Would create a type called unit that you could declare just like a integer or real number.

Example:

unit1 as unit
unit1.name$ = "7th Guards Motorized Rifle Division"
unit1.x = 3
unit1.y = 7

There are plenty of examples in the tutorials at the top of the newcomer section.
Revolution
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location:
Posted: 28th Feb 2007 18:18
thanks, i managed to find one that explained type and global nicely but not #const

Login to post a reply

Server time is: 2024-09-25 19:23:18
Your offset time is: 2024-09-25 19:23:18