Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

string to integer

Alberto McGettigan
Registered User
Join date: 14 Jun 2005
Posts: 57
08-02-2005 15:26
Is there an easy way to convert a string say"1" to the number 1 or the string"one"
without a bucnh of IF's?
cua Curie
secondlifes.com/*****
Join date: 14 Nov 2003
Posts: 196
08-02-2005 15:34
CODE

default
{
state_entry()
{
integer variable=2;
list numbers=["zero","one","two","three","four","five","six","seven","eight","nine","ten"];
string foo=llList2String(numbers,variable);
llSay(0,foo);
}


}


You can write it the other way around as well. That what you meant?
_____________________
"It is better to keep your mouth shut and appear stupid than to open it and remove all doubt." - Mark Twain

"We are what we pretend to be, so we must be careful what we pretend to be." - Kurt Vonnegut
Alberto McGettigan
Registered User
Join date: 14 Jun 2005
Posts: 57
08-02-2005 15:45
close. How do you get there if your starting with the string "2"?
Editorial Hare
Second Life Resident
Join date: 11 Nov 2004
Posts: 116
08-02-2005 15:55
CODE
string number=2;
string foo=llList2String(numbers,(integer)number);
_____________________
Please see my alternate account disclaimer here

The world tolerates conceit from those who are successful, but not from anybody else. - John Blake
cua Curie
secondlifes.com/*****
Join date: 14 Nov 2003
Posts: 196
08-02-2005 15:57
Just cast the string as an integer like (integer)variable
_____________________
"It is better to keep your mouth shut and appear stupid than to open it and remove all doubt." - Mark Twain

"We are what we pretend to be, so we must be careful what we pretend to be." - Kurt Vonnegut
cua Curie
secondlifes.com/*****
Join date: 14 Nov 2003
Posts: 196
08-02-2005 15:58
lol like Editorial said.
_____________________
"It is better to keep your mouth shut and appear stupid than to open it and remove all doubt." - Mark Twain

"We are what we pretend to be, so we must be careful what we pretend to be." - Kurt Vonnegut
Alberto McGettigan
Registered User
Join date: 14 Jun 2005
Posts: 57
08-02-2005 16:00
ahhh ok ill try that
THANK YOU so much!