Transform a String into an Integer

About advanced scenes, and the Thyme scripting language used in Algodoo.

Transform a String into an Integer

Postby roobre » Sun Jul 11, 2010 3:15 pm

Hi!
I'm trying to het the value stored in a Box's text, but I get a string. I need an Integer, so I tried to use some of C++ functions ( atoi() ), but it doesn't seem to work...

How can I do this?
User avatar
roobre
 
Posts: 11
Joined: Sat Sep 05, 2009 5:14 pm

Re: Transform a String into an Integer

Postby tatt61880 » Sun Jul 11, 2010 3:24 pm

math.toInt("1") returns 1

Btw,
math.toFloat("3.14") returns 3.14
math.toBool("1") returns true
math.toBool("0") returns false

(Note: Currently, all of them are Algodoo only.)
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: Transform a String into an Integer

Postby roobre » Sun Jul 11, 2010 3:25 pm

Thanks! it works!

;)

Regards
User avatar
roobre
 
Posts: 11
Joined: Sat Sep 05, 2009 5:14 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 3 guests