Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

substring problem..

Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
11-18-2007 07:02
So I'm writing a script that uses it's description for values. But the only way i know how to use a description and still get multiple values is if the digits count for the values are all the same, so that I always get the same string length.

EXAMPLE of my description:
"005,015,010,025,050"

I have to keep all the values equalling 3 digits so that I know for sure that the values will always be in the same place, as long as they don't go into the 4 digit places... But I've been wondering, just for educational reasons how to have it simply read what's in between certain separators; a script that simply takes the 1st value so whatever is in between each comma is the consecutive value, and so on...

Anyone know how this can be achieved? Or should I maybe just stick with llGetNotecardLine? :confused:
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
11-18-2007 07:16
From: Aniam Ingmann
So I'm writing a script that uses it's description for values. But the only way i know how to use a description and still get multiple values is if the digits count for the values are all the same, so that I always get the same string length.

EXAMPLE of my description:
"005,015,010,025,050"

I have to keep all the values equalling 3 digits so that I know for sure that the values will always be in the same place, as long as they don't go into the 4 digit places... But I've been wondering, just for educational reasons how to have it simply read what's in between certain separators; a script that simply takes the 1st value so whatever is in between each comma is the consecutive value, and so on...

Anyone know how this can be achieved? Or should I maybe just stick with llGetNotecardLine? :confused:


http://lslwiki.net/lslwiki/wakka.php?wakka=llCSV2List - does exactly what you're looking for.
_____________________
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-18-2007 18:12
see also llParseStringKeppNulls, to give you custom seperators...

you can still do it with string manipulation, using
sting myString = llGetObjecDesc;
integer vIntSearch = llSubStringIndex( myString, "," );
datastring = llGetSubString( myString, 0, vIntSearch -1 );
myString = llDeleteSubString( myString, 0, vIntSearch );
//-- wash rinse repeat

in some cases this may be less memory intesive, but certainly slower to load... but it avoids having to convert all your variables from a list at some point if it's important..
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
11-19-2007 03:19
also, dont forget llParseString2List()....

string myString = "1,2,3,4,5";
list myList = llParseString2List (myString, "[,],[]);

...will dump the values from the string into a list.
Jana Kamachi
Registered User
Join date: 19 Apr 2007
Posts: 111
11-19-2007 03:22
http://lslwiki.net/lslwiki/wakka.php?wakka=List

The basics never killed anyone.