Category:LSL String/ja
LSL ポータル | 関数 | イベント | 型 | 演算子 | 定数 | 実行制御 | スクリプトライブラリ | カテゴリ別スクリプトライブラリ | チュートリアル |
stringはテキストデータです。stringの長さは、有効なスクリプト容量の限界までです。 Stringの値はLSLテキストを定義するときに、ダブルクォーテーション(" ")て囲まれます。いくつかの文字はエスケープされる必要があるだろうけれど、stringで用いることができるでしょう。
stringは+演算子を用いて結合させることができます。
部分文字 | 置換されるもの |
---|---|
\t | 4スペース |
\n | 改行 |
\" | ダブルクオーテーション |
\\ | バックスラッシュ |
String 例: "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.
Note: People who come to LSL from C and Java and such languages may find these LSL string escape rules confusing while new. LSL "\n" means llUnescapeURL("%0A"), same as C and Java, but "\t" means llUnescapeURL("%20%20%20%20") rather than llUnescapeURL("%09"), and "\r" means "r" rather than llUnescapeURL("%0D"), etc.
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 |
Operators
See Operators for more information.
Combine: value1 + value2
(value1 + value2)
Combines two strings into a single string without modifying the inputs. Appends value2 to value1 and returns the resulting string.
• expression | value1 | – | string expression or constant | |
• expression | value2 | – | string expression or constant |
Comparison: value1 == value2
(value1 == value2)
Compares two strings, returns one if same length and same characters, else returns zero.
This operator works exactly like !strcmp(value1, value2)
in C, thus technically differs from the counterintuitive behavior of the == operator in C and in Java.
• expression | value1 | – | string expression or constant | |
• expression | value2 | – | string expression or constant |
Comparison: value1 != value2
(value1 != value2)
Compares two strings, returns zero if same length and same characters, otherwise non-zero.
This operator works exactly like strcmp(value1, value2)
in C, thus technically differs from the counterintuitive behavior of the != operator in C and in Java.
• expression | value1 | – | string expression or constant | |
• expression | value2 | – | string 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 |
Examples
• | SplitLine | – | Insert 'new line' escape codes at certain positions of a string |
Pages in category "LSL String/ja"
The following 33 pages are in this category, out of 33 total.