Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Is it possible to turn a string into a integer?

Piginawig Lock
Person
Join date: 11 Oct 2006
Posts: 56
04-11-2007 08:29
I currently have this is my script:

string desc = llGetObjectDesc();
string righttime = llGetSubString(desc, 2, 5);


But because the description has to be a string I can't get this to work in the same script:

llSetTimerEvent(60*righttime);

Is there a way to make it so I can multiply 60 by the righttime from the description?


Edit: If you get what I am saying at all.
_____________________
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
04-11-2007 08:34
llSetTimerEvent(60 * (integer)righttime);

There is no verification with this though. Feed it something that doesn't contain just an integer and you'll probably get some unexpected results.
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
04-11-2007 12:26
I've found that if you accidentally feed a script like that with any string who's first character is not an integer, it returns 0. If the first character is an integer, it will read a number until a letter is reached and then stop there.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
04-11-2007 13:26
From: Kenn Nilsson
I've found that if you accidentally feed a script like that with any string who's first character is not an integer, it returns 0. If the first character is an integer, it will read a number until a letter is reached and then stop there.


As Kenn stated casting of strings will terminate at the first unrecognised/illegal character. This is a hold over from the standard C libraries used by the client and actually quite a useful feature at times.
Piginawig Lock
Person
Join date: 11 Oct 2006
Posts: 56
04-11-2007 15:48
Thank you to all that replied, I'll get in-world and test it out.
_____________________