Category:LSL String

From Second Life Wiki
Revision as of 16:16, 11 March 2007 by Strife Onizuka (talk | contribs)
Jump to navigation Jump to search

A string is a text data. String values are enclosed in quotes when you define them. You can use every letter or number in a string!


String examples:

"Hello Avatar!", "Yes", "No", "It's 10 o'clock.", "I am 21 years old!"

Variable: string name;

string name;

Declares a variable of type string named name, with the value ""

Variable: string name = value;

string name;

Declares a variable of type string named name, with the value value.

Useful Functions

string TrimRight(string src, string chrs)
{
	integer i = llStringLength(src);
	do;while(~llSubStringIndex(chrs, llGetSubString(src, i = ~ -i, i)) && i);
	return llDeleteSubString(src, -~i, 0xFFFF);
}

string TrimLeft(string src, string chrs)
{
	integer i = ~llStringLength(src);
	do;while(i && ~llSubStringIndex(chrs, llGetSubString(src, (i = -~i), i)));
	return llDeleteSubString(src, 0xFFFF0000, ~-i);
}