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 / Printing data to screen as well as strings: using dbText or dbPrint?

Author
Message
bigbrother 2000
21
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 29th Oct 2006 20:08
Hello,

My aim is to print out some data to screen based on which object the mouse it positioned at.

the 'string' would be like ("OBJECT: " + objectNumber + " COLOR: "+stringColor);

What is the best way to do this in the sdk. the text and print commands do not accept strings so they cannot be created like above.

What options are available to construct and print data to the screen of different types above?

thanks for any help

SNOW ISLAND : www.snowisland.co.uk
BEWARE THE MOON : www.bewarethemoon.co.uk
ALIEN INVASION : www.alien-invasion.co.uk
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 29th Oct 2006 20:12
Quote: "the text and print commands do not accept strings so they cannot be created like above."

Yes they do - although actually, in C, a string is a NULL terminated array of characters.

Visit my web site for real bangin' stuff. Word.
bigbrother 2000
21
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 29th Oct 2006 20:19
string qwe = "x";

dbText(dbMouseX()+ 10,dbMouseY()+10,qwe);

I must be passing in the string wrong if they accept them, it compiles with this error:
error C2664: 'dbText' : cannot convert parameter 3 from 'std::string' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

SNOW ISLAND : www.snowisland.co.uk
BEWARE THE MOON : www.bewarethemoon.co.uk
ALIEN INVASION : www.alien-invasion.co.uk
EddieB
20
Years of Service
User Offline
Joined: 29th Sep 2004
Location: United Kingdom
Posted: 29th Oct 2006 20:52
string qwe = "x";

dbText(dbMouseX()+ 10,dbMouseY()+10,qwe.c_str());
Jna99
19
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 29th Oct 2006 22:48 Edited at: 29th Oct 2006 22:49
How I print variables...except BOOL type

bigbrother 2000
21
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 30th Oct 2006 16:56
Thanks EddieB,

I tried the .c_str()

this error was returned:

error C2664: 'dbText' : cannot convert parameter 3 from 'const char *' to 'char *'
Conversion loses qualifiers

Am I missing anything else:

dbText(dbMouseX()+ 10,dbMouseY()+10,qwe.c_str());

SNOW ISLAND : www.snowisland.co.uk
BEWARE THE MOON : www.bewarethemoon.co.uk
ALIEN INVASION : www.alien-invasion.co.uk
bigbrother 2000
21
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 31st Oct 2006 16:10
Anyone else have problems outputing strings using the dbText command, the stringvariable.c_str() resulted in an error, see above,

Anyone got working code of printing strings to screen?

SNOW ISLAND : www.snowisland.co.uk
BEWARE THE MOON : www.bewarethemoon.co.uk
ALIEN INVASION : www.alien-invasion.co.uk
Kaiyodo
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: UK
Posted: 31st Oct 2006 17:08
You'll need to cast off the const first ...

EddieB
20
Years of Service
User Offline
Joined: 29th Sep 2004
Location: United Kingdom
Posted: 31st Oct 2006 18:51
Or you could just do:

bigbrother 2000
21
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 31st Oct 2006 23:50
Thanks Kaiyodo i got it compiling with the suggested add on.

this is more of a C++ thing now rather than a SDK, but i would like to create a string with a string and a variable, concatenation, is this possible, what type of code will allow for this to happen as the code below does not compile?

qwe = ("FLOOR: " + floorNo);


dbText(dbMouseX()+ 10,dbMouseY()+10,const_cast<char *>(qwe.c_str()));

SNOW ISLAND : www.snowisland.co.uk
BEWARE THE MOON : www.bewarethemoon.co.uk
ALIEN INVASION : www.alien-invasion.co.uk
Miguel Melo
19
Years of Service
User Offline
Joined: 8th Aug 2005
Location:
Posted: 1st Nov 2006 00:11
Try something like this (from the top of my head, not tried it):

qwe = string("FLOOR: ") + _itoa( floorNo );

or, if that fails,

qwe = string("FLOOR: ") + string(_itoa( floorNo ));

I have vague plans for World Domination

Login to post a reply

Server time is: 2024-11-19 09:21:20
Your offset time is: 2024-11-19 09:21:20