For/ja
< For
| LSL ポータル | 関数 | イベント | 型 | 演算子 | 定数 | 実行制御 | スクリプトライブラリ | カテゴリ別スクリプトライブラリ | チュートリアル |
for( 初期化; 終了条件; 増分処理 ) ループ
| • | 初期化 | – | 終了条件をチェックする前に一度だけ実行される. | |
| • | 終了条件 | – | この文の実行結果が真のときはループが実行される. | |
| • | 増分処理 | – | ループの後に実行され, その後で終了条件が再びチェックされる. | |
| • | ループ | – | 単文でもブロック文でも空文でもよい. |
どの文も空文でもよい.
Specification
| Type | Condition |
|---|---|
| integer | True if it is not zero. |
| float | True if it is not zero.[1] |
| string | True if its length is not zero. |
| key | True only if it is a valid key and not NULL_KEY. |
| vector | True if the vector is not ZERO_VECTOR. |
| rotation | True if the rotation is not ZERO_ROTATION. |
| list | True if the length is not zero. Note that correct behavior is only seen with Mono-compiled scripts; LSO-compiled scripts incorrectly resolve to false if the list is non-empty: BUG-230728 |
Examples
//単文の場合.
integer a = 0;
integer b = 10;
for(; a < b; ++a)
llOwnerSay((string)a);
//ブロック文の場合
integer a = 0;
integer b = 10;
for(; a < b; ++a)
{
llOwnerSay((string)a);
llOwnerSay((string)a);
}
//空文の場合 integer a = 0; integer b = 10; for(; a < b; llOwnerSay((string)(a++)));
Notes
forループは下記のwhileループと等価である.
初期化;
while(終了条件);
{
ループ;
増分処理;
}
Deep Notes
Footnotes
- ^ The OpenSim LSL compiler will not do this implicitly. You will need to use an explicit check.