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 / dbText() Strings and HardText Question...

Author
Message
JoeOh
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 2nd Jul 2011 19:28
I know that in DBPro I can use this line:

Text 0,0,"Hello World" + str(varX)

and it works just fine. I try to do the '+' string adding in DarkDGK but it doesn't want to play ball. What am I doing wrong?

Home is where my souped-up computer is...
Red Eye
15
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 2nd Jul 2011 20:16 Edited at: 2nd Jul 2011 20:17
You can not add two pointers. Altough you can add two strings from the #include <string> class, like this:



.c_str() is very unsafe and so i recommend using it only when you are passing the string over into a darkgdk command, so don't do something like this to use the char* elsewere:



...very unreliable. I recommand using strings only, and .c_str() when you pass it over to a darkgdk command.

Altough you could make your own TextConvert class, to easy convert int's float's and other types to strings and vice versa.

Cheers,

Leo

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 3rd Jul 2011 02:20
You can use:


I set up a "char tmpString[256];" as a global variable in all my application just for stuff like that.

The fastest code is the code never written.
Serial Velocity
15
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 12th Jul 2011 21:08 Edited at: 12th Jul 2011 21:12
I recommend using the std::string class like RedEye suggested, but here are some helper functions that I wrote for my project which you might find useful.

Includes:


Functions (put this at the top of the source file or tucked in a header file somewhere):


and this is how you would use them:


Login to post a reply

Server time is: 2024-05-18 09:29:13
Your offset time is: 2024-05-18 09:29:13