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 / setting global variables

Author
Message
Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 26th Oct 2008 20:08
I am new to darkbasic pro, when I try to set a global for a variable I get an error message, if I delete the word global my program runs ok
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Oct 2008 20:24
What code do you use? What error message do you get?

Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 26th Oct 2008 22:16
As soon as I type in the word global and press F5 to run I get the error message syntax error: unknown command. I am trying a copy of hangman from the book "Hands on darkbasic pro " the compiler will not accept the word global. Is the book wrong?
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 26th Oct 2008 23:46 Edited at: 26th Oct 2008 23:48
GLOBAL makes the specified variable global and is used as follows:

GLOBAL (variable name)
ex:
GLOBAL MyVariable

Or it could be used like this:

GLOBAL (variable name) AS (variable type)
ex:
GLOBAL MyVariable AS Integer

Which would make the variable only be able to hold integers no matter what it's called.

Some variable types include:
INTEGER
FLOAT
DWORD
STRING
BOOLEAN
BYTE

Plus some others I did not mention

Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 27th Oct 2008 16:54
I type in global word$ the compiler will not accept this, if I delete global the program runs


anymore thoughts 0n this
Captain IceT
15
Years of Service
User Offline
Joined: 21st Oct 2008
Location: Boat Murdered, and Im still laughing!
Posted: 27th Oct 2008 17:04
What version of DBPro are you using?

"Dwarf Fortress has taught me that all the world's problems would be substantially reduced had our parent civilizations never minted more than four stacks of coins."
- DwarfFortressWiki
Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 27th Oct 2008 17:08
I am using dark basicpro v1.13 enhanced

the problem line is


global word$
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th Oct 2008 21:39
Or use DBEdit (I think it's called). It has a nice pre-compiler that can give you globals, types, etc.

Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 28th Oct 2008 22:52
Thanks for the info guys that hes cleared the matter

cheers.

Login to post a reply

Server time is: 2024-09-27 22:31:33
Your offset time is: 2024-09-27 22:31:33