Difference between revisions of "Category:LSL String"

From Second Life Wiki
Jump to navigation Jump to search
Line 1: Line 1:
{{LSL Header}}
{{LSL Header}}
<div style="float:right">__TOC__</div>
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!
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:
String examples:
<pre>"Hello Avatar!", "Yes", "No", "It's 10 o'clock.", "I am 21 years old!"</pre>
<pre>"Hello Avatar!"
"Yes"
"No"
"It's 10 o'clock."
"I am 21 years old!"
EOF</pre>


{{#vardefine:p_name_desc|variable name
}}{{#vardefine:p_value_desc|string expression or constant
}}{{#vardefine:p_value_t_desc|expression or constant
}}
<div id="box">
<div id="box">
== Variable: string {{HoverText|name|variable name}}; ==
== Variable: string {{LSL Param|name}}; ==
<div style="padding: 0.5em;">
<div style="padding: 0.5em;">
<pre>string name;</pre>
<pre>string name;</pre>
Declares a variable of type string named '''name''', with the value {{HoverText|""|empty string}}
Declares a variable of type string named '''name''', with the value {{HoverText|""|empty string}}
{|
{{LSL DefineRow|variable|name|{{#var:p_name_desc}}}}
|}
</div></div>
</div></div>
<div id="box">
<div id="box">
== Variable: string {{HoverText|name|variable name}} {{=}} value; ==
== Variable: string {{LSL Param|name}} {{=}} {{LSL Param|value}}; ==
<div style="padding: 0.5em;">
<pre>string name = value;</pre>
Declares a variable of type string named '''name''', with the value '''value'''.
{|
{{LSL DefineRow|variable|name|{{#var:p_name_desc}}}}
{{LSL DefineRow|expression|value|{{#var:p_value_desc}}}}
|}
</div></div>
<div id="box">
== Typecast: (string){{LSL Param|value_t|value}} ==
<div style="padding: 0.5em;">
<div style="padding: 0.5em;">
<pre>string name;</pre>
<pre>string name;</pre>
Declares a variable of type string named '''name''', with the value '''value'''.
Declares a variable of type string named '''name''', with the value '''value'''.
{|
{{LSL DefineRow|expression|value|{{#var:p_name_desc}}}}
|}
</div></div>
</div></div>
{{Box|Useful Functions|<pre>
{{Box|Useful Functions|<pre>

Revision as of 18:13, 11 March 2007

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!"
EOF


Variable: string name;

string name;

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

• variable name variable name

Variable: string name = value;

string name = value;

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

• variable name variable name
• expression value string expression or constant

Typecast: (string)value

string name;

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

• expression value variable name

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);
}