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.

Dark GDK / dbVal bug & alternative

Author
Message
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 12th Sep 2008 18:09 Edited at: 12th Sep 2008 18:20
Hi,
I have found a bug with dbVal function, try this code:

Only returns -2 which messes up my program

I also tried this using the c++ function

Still returns -2

Is there an alternative to dbVal in C++?

Thanks,
Alex

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Sep 2008 19:11
Yes, instead of using atoi (ascii to integer), use atof (ascii to float), or strtod (a slightly more complex equivalent of atof).

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 12th Sep 2008 23:26
That's because dbVal returns an int. Doing what IanM said will work just fine.
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 13th Sep 2008 00:13
Thanks for help, dbVal, atoi, atof all dont work with the code above when integers, however when they are floats they all will work

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 13th Sep 2008 04:06
Uh...

DUH?

atof.

Let's break it down.

a = ASCII.
to = to.
f = float.

ASCII to Float

...

So, use atoi when its an integer, and atof when it's a float.
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 13th Sep 2008 08:10
Not every is fluent in English, you know. Imagine using a programing language centered around Spanish or German. Not that easy if you're born with English.

Point being: Perfect English not requiring

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo

Login to post a reply

Server time is: 2024-09-30 05:34:26
Your offset time is: 2024-09-30 05:34:26