Difference between revisions of "Category:LSL String"
Jump to navigation
Jump to search
DuraS Torok (talk | contribs) m (concatenation is important) |
|||
Line 1: | Line 1: | ||
{{LSL Header}} | {{LSL Header}} | ||
<div style="float:right">__TOC__</div> | <div style="float:right">__TOC__</div> | ||
A string is text data. The length of a string is only limited by available [[script memory]]. String values are enclosed in quotes when defined in LSL text. Any character may be used in a string though some will need to be escaped. | A string is text data. The length of a string is only limited by available [[script memory]]. String values are enclosed in double quotes when defined in LSL text. Any character may be used in a string though some will need to be escaped. | ||
Strings can be concatenated using the '''+''' operator. | |||
<div style="float:left"> | <div style="float:left"> | ||
Line 27: | Line 29: | ||
"It's 10 o'clock." | "It's 10 o'clock." | ||
"I am 21 years old!" | "I am 21 years old!" | ||
"Help " + "me" | |||
EOF | EOF | ||
//The following two strings have the same value. | //The following two strings have the same value. |
Revision as of 05:52, 17 May 2007
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
A string is text data. The length of a string is only limited by available script memory. String values are enclosed in double quotes when defined in LSL text. Any character may be used in a string though some will need to be escaped.
Strings can be concatenated using the + operator.
Substring | Replaced with |
---|---|
\t | four spaces |
\n | new line |
\" | double quote |
\\ | backslash |
String examples: "Hello Avatar!" "Yes" "No" "It's 10 o'clock." "I am 21 years old!" "Help " + "me" EOF //The following two strings have the same value. "I scream,\nyou scream,\nwe all scream,\nfor ice-cream!" "I scream, you scream, we all scream, for ice-cream!" |
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)value
Converts value to a value of type string.
• expression | value | – | expression or constant |
Examples
integer int = 48934; string str = (string)int; string str_2; str_2 = str;
Useful Functions
//Use these functions instead of llStringTrim if you want to trim characters other then spaces. 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); } string TrimBoth(string src, string chrs) { integer i = ~llStringLength(src); do;while(i && ~llSubStringIndex(chrs, llGetSubString(src, (i = -~i), i))); i = llStringLength(src = llDeleteSubString(src, 0xFFFF0000, (~-(i)))); do;while(~llSubStringIndex(chrs, llGetSubString(src, (i = ~-i), i)) && i); return llDeleteSubString(src, (-~(i)), 0xFFFF); }
Subcategories
This category has the following 2 subcategories, out of 2 total.
Pages in category "LSL String"
The following 46 pages are in this category, out of 46 total.