Difference between revisions of "Category:LSL String"

From Second Life Wiki
Jump to navigation Jump to search
Line 6: Line 6:
<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!"</pre>


<div id="box">{{#if: Variable: string {{HoverText|name|variable name}} |{{#switch:{{{3|2}}}|
<div id="box">
|1=&#32;
== Variable: string {{HoverText|name|variable name}}; ==
= Variable: string {{HoverText|name|variable name}} =
|2=&#32;
== Variable: string {{HoverText|name|variable name}} ==
|3=&#32;
=== Variable: string {{HoverText|name|variable name}} ===
|4=&#32;
==== Variable: string {{HoverText|name|variable name}} ====
|5=&#32;
===== Variable: string {{HoverText|name|variable name}} =====
|6=&#32;
====== Variable: string {{HoverText|name|variable name}} ======
|7=&#32;
======= Variable: string {{HoverText|name|variable name}} =======
|8=&#32;
======== Variable: string {{HoverText|name|variable 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  
Declares a variable of type string named '''name''', with the value {{HoverText|""|empty string}}
</div></div>
<div id="box">
== Variable: string {{HoverText|name|variable name}} {{=}} value; ==
<div style="padding: 0.5em;">
<pre>string name;</pre>
Declares a variable of type string named '''name''', with the value '''value'''.
</div></div>
</div></div>
{{Box|Useful Functions|<pre>
{{Box|Useful Functions|<pre>

Revision as of 16:16, 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!"

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