Difference between revisions of "Category:LSL String"
(Added a note about escape codes, and when they get translated (and when they don't)) |
|||
Line 90: | Line 90: | ||
== Useful Functions == | == Useful Functions == | ||
<div style="padding: 0.5em;"> | <div style="padding: 0.5em;"> | ||
=== String functions in the [[Library_Combined_Library|CombinedLibrary]] === | |||
{| | |||
{{LSL DefineRow||[[Library_Combined_Library#str_replace|str_replace]]|replace all instances of a string with another string in a target string.}} | |||
string | {{LSL DefineRow||[[Library_Combined_Library#Trim|TrimRight]]|Trim characters from the right end of a string}} | ||
{ | {{LSL DefineRow||[[Library_Combined_Library#Trim|TrimLeft]]|Trim characters from the left end of a string}} | ||
{{LSL DefineRow||[[Library_Combined_Library#Trim|TrimBoth]]|Trim characters from the both ends of a string}} | |||
|} | |||
} | |||
{ | |||
} | |||
</div></div> | </div></div> |
Revision as of 05:30, 9 August 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!" |
Note: escape codes (listed above) are translated when the script is compiled, and not while it's running. The result: only strings that are inside your script when it is compiled will get, say, \n turned into a "new line" character. Text you read in from a notecard, chat, http, etc, will not be checked for escape codes -- that same \n typed in a notecard doesn't automatically turn into a "new line" character in any case. You'll have to do that yourself, if you really really need it for some reason.
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
String functions in the CombinedLibrary
• | str_replace | – | replace all instances of a string with another string in a target string. | |
• | TrimRight | – | Trim characters from the right end of a string | |
• | TrimLeft | – | Trim characters from the left end of a string | |
• | TrimBoth | – | Trim characters from the both ends of a string |
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.