Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Remove Spaces?

Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
12-11-2009 13:17
Is there a way to remove the spaces out of say "go to <100, 20, 20>"?

so it returns goto<100,20,20>

Then a way to just return the vector <100,20,20>

There doesn't seem to be many string editing functions?
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
12-11-2009 13:29
?
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
12-11-2009 13:42
You can skip llDumpList2String if there is no replacement text, a cast will do.
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
12-11-2009 15:42
is there no function to just say

Get string from < to >

then another to remove spaces?
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
12-11-2009 15:56
This ought to work unless I made a typo or two..........

CODE

default
{
touch_start(integer num)
{
string stuff = "Put your < stuff > here";
integer leftBrack = llSubStringIndex(stuff,"< ");//Take out the extra space after the <
integer rightBrack = llSubStringIndex(stuff,">");
string newstuff = llGetSubString(stuff,leftBrack,rightBrack);
string finalstuff = llDumpList2String(llParseString2List(newstuff,[" "],[""]),"");
llSay(0, finalstuff);
}
}


ETA: Ooops.... forgot that you wanted to keep the brackets... I fixed it.

ETA (again): OK, so there WAS a typo. Fixed that too, and tested it in world. It works like a dream. :)
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
12-11-2009 23:51
Or llike this:

CODE


string NoSpacesString( string Str )
{
return llDumpList2String(llParseString2List(Str,[" "],[]),"");
}

default
{
state_entry()
{
llSay(0, NoSpacesString("go to <100, 20, 20>"));
}
}

Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
12-12-2009 05:32
Yup, but the OP wanted to remove the "go to" as well, which is why I had to put the SubString stuff in my post.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
Oops
12-12-2009 06:07
Should have read the whole question. :o

Actually Viktoria had the best sollution then.

CODE

string str = "go to <100, 20, 20>";
vector v = (vector)str;
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-12-2009 06:38
vStrTest = "asdf asdf <1,2,3> asdf"
vStrTest = llGetSubString( vStrTest, 0, llSubStringIndex( vStrTest, ">" ) );
vStrTest = llGetSubString( vStrTest, llSubStringIndex( vStrTest, "<" ), -1 );

that'll either return the brackets and what's between them, or a single character if it's not found.
_____________________
|
| . "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...
| -