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.

DarkBASIC Professional Discussion / Integer to String

Author
Message
ArcherSam
15
Years of Service
User Offline
Joined: 13th Mar 2011
Location: Florida, US
Posted: 25th Apr 2011 00:33 Edited at: 25th Apr 2011 00:33
I need to convert an integer to a string in order to use the CENTER TEXT command <CENTER TEXT X, Y, String>.



Sam
Brendy boy
21
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 25th Apr 2011 00:39
use this:
CENTER TEXT SCREEN WIDTH() / 2, 10, str$(time)

ArcherSam
15
Years of Service
User Offline
Joined: 13th Mar 2011
Location: Florida, US
Posted: 25th Apr 2011 01:14 Edited at: 25th Apr 2011 01:15
Wow, that was easy! Thanks Brendy boy.

Just for future reference, are the cast below correct?

str$
str$(int)
str$(real#)

int
int(str$)
int(real#)

real#
real#(str$)
real#(int)

Sam
Brendy boy
21
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 25th Apr 2011 01:18
yes and no

if you want to cast a string to numeric value use val, eg. pi#=val("3.14")
if you want to cast a numeric value to string use str$, eg. pi$=str$(pi#)

ArcherSam
15
Years of Service
User Offline
Joined: 13th Mar 2011
Location: Florida, US
Posted: 25th Apr 2011 01:23
Thanks again Brendy boy! I know soon or later I come across the need for casting string to numeric and vice versa.

Login to post a reply

Server time is: 2026-07-18 06:41:17
Your offset time is: 2026-07-18 06:41:17