For/ja

From Second Life Wiki
< For
Revision as of 22:29, 4 December 2007 by Coffee Mills (talk | contribs)
Jump to navigation Jump to search

for( 初期化; 条件式; 増分処理ループ

•  初期化 条件式をチェックする前に一度だけ実行される.
•  条件式 この文の実行結果が真のときはループが実行される.
•  増分処理 ループの後に実行され, その後で条件式が再びチェックされる.
•  ループ 単文でもブロック文でも空文でもよい.


どの文も空文でもよい.

Specification

Conditional Types
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

Search JIRA for related Issues

Footnotes

  1. ^ The OpenSim LSL compiler will not do this implicitly. You will need to use an explicit check.