Difference between revisions of "Category:LSL String/ja"

From Second Life Wiki
Jump to navigation Jump to search
Line 32: Line 32:
"Help " + "me"
"Help " + "me"
EOF
EOF
//The following two strings have the same value.
//以下の2つのstringは同じ値です。
"I scream,\nyou scream,\nwe all scream,\nfor ice-cream!"
"I scream,\nyou scream,\nwe all scream,\nfor ice-cream!"
"I scream,
"I scream,
Line 41: Line 41:
|}
|}


Note: Escape codes (listed above) are translated when the script is compiled, and not while it's running.
Note: エスケープコード(上記一覧)はスクリプトがコンパイルされるときに翻訳され、動いてる間はされません。
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.
stringはコンパイルされたとき、結果としてスクリプト内部の\nを"改行"文字に変換するでしょう。ノートカード、チャット、httpその他から読み込むテキストはエスケープコードではチェックされませんから、ノートカードでの\n入力は自動で"改行"文字には変換されません。自らしなければなりませんが、本当に本当に必要な場合だけにすべきです。


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.
Note: CとJavaや同様な言語からLSLに入った人は、始めたばかりの間はLSL stringのエスケープルールで混乱するでしょう。 LSLの"\n"の意味はllUnescapeURL("%0A")で、CとJavaに似てますが、"\t"の意味はllUnescapeURL("%09")よりllUnescapeURL("%20%20%20%20") が最適で、"\r"の意味はllUnescapeURL("%0D")よりも"r"が最適、などなど。


{{#vardefine:p_name_desc|variable name
{{#vardefine:p_name_desc|変数名
}}{{#vardefine:p_value_desc|string expression or constant
}}{{#vardefine:p_value_desc|string 要素もしくは定型値
}}{{#vardefine:p_value_t_desc|expression or constant
}}{{#vardefine:p_value_t_desc|要素もしくは定型値
}}
}}
<div id="box">
<div id="box">
== Variable: string {{LSL Param|name}}; ==
== 変数: string {{LSL Param|name}}; ==
<div style="padding: 0.5em;">
<div style="padding: 0.5em;">
<pre>string name;</pre>
<pre>string name;</pre>

Revision as of 08:40, 2 January 2008

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
//以下の2つのstringは同じ値です。
"I scream,\nyou scream,\nwe all scream,\nfor ice-cream!"
"I scream,
you scream,
we all scream,
for ice-cream!"

Note: エスケープコード(上記一覧)はスクリプトがコンパイルされるときに翻訳され、動いてる間はされません。 stringはコンパイルされたとき、結果としてスクリプト内部の\nを"改行"文字に変換するでしょう。ノートカード、チャット、httpその他から読み込むテキストはエスケープコードではチェックされませんから、ノートカードでの\n入力は自動で"改行"文字には変換されません。自らしなければなりませんが、本当に本当に必要な場合だけにすべきです。

Note: CとJavaや同様な言語からLSLに入った人は、始めたばかりの間はLSL stringのエスケープルールで混乱するでしょう。 LSLの"\n"の意味はllUnescapeURL("%0A")で、CとJavaに似てますが、"\t"の意味はllUnescapeURL("%09")よりllUnescapeURL("%20%20%20%20") が最適で、"\r"の意味はllUnescapeURL("%0D")よりも"r"が最適、などなど。


変数: string name;

string name;

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

• variable name 変数名

Variable: string name = value;

string name = value;

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

• variable name 変数名
• expression value string 要素もしくは定型値

Typecast: (string)value

(string)value

Converts value to a value of type string.

• expression value 要素もしくは定型値

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 value2 string 要素もしくは定型値

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 value2 string 要素もしくは定型値

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 value2 string 要素もしくは定型値

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