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 / Can't declare variable as real

Author
Message
treeman
14
Years of Service
User Offline
Joined: 15th Sep 2010
Location: My Cave
Posted: 16th Sep 2010 03:47
I can declare variables as integer, string, boolean etc but when I try to use "real" the word doesn't get highlighted in blue by the editor and I get a syntax error when I run my code.

e.g.


What am I supposed to use for declaration of decimal variables?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Sep 2010 15:41
It's actually 'float' - the documentation in that section is just a little out of date.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
treeman
14
Years of Service
User Offline
Joined: 15th Sep 2010
Location: My Cave
Posted: 17th Sep 2010 03:39
Thanks, I figured out that it was float eventually by myself .
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 17th Sep 2010 08:30 Edited at: 17th Sep 2010 08:39
Hi Treeman & IanM. I've also seen programmers using # in their coding with regards to declaring variables. Is this a recommended practice?

As per this code; I find a few things that I'm still confused with...

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Sep 2010 11:37 Edited at: 17th Sep 2010 11:38
Hi Burning Feet Man,

That custom dates back from the Dark Basic Classic compiler. A float was always appended by a # and a string was appended with a $ (nothing was an integer). It allows you to specify the variable's type without actually declaring them. Dark Basic Professional still allows this, so we (I do at least) still make use of that .

Cheers!
Sven B

Login to post a reply

Server time is: 2024-11-16 16:57:29
Your offset time is: 2024-11-16 16:57:29