Difference between revisions of "For/ja"

From Second Life Wiki
< For
Jump to navigation Jump to search
(New page: {{Multi-lang}} {{LSL_Conditional |statement=for |statement_header |statement_desc=どの文も空文でもよい. |statement_end=ループ |statement_end_desc=単文でもブロック文...)
 
m
Line 6: Line 6:
|statement_end=ループ
|statement_end=ループ
|statement_end_desc=単文でもブロック文でも空文でもよい.
|statement_end_desc=単文でもブロック文でも空文でもよい.
|p1_name=初期化|p1_desc='''終了条件'''をチェックする前に一度だけ実行される.
|p1_name=初期化|p1_desc='''条件式'''をチェックする前に一度だけ実行される.
|p2_name=終了条件|p2_desc=この文の実行結果が真のときは'''ループ'''が実行される.
|p2_name=条件式|p2_desc=この文の実行結果が真のときは'''ループ'''が実行される.
|p3_name=増分処理|p3_desc='''ループ'''の後に実行され, その後で'''終了条件'''が再びチェックされる.  
|p3_name=増分処理|p3_desc='''ループ'''の後に実行され, その後で'''条件式'''が再びチェックされる.  
|constants
|constants
|spec
|spec
Line 41: Line 41:
<pre>
<pre>
初期化;
初期化;
while(終了条件);
while(条件式)
{
{
     ループ;
     ループ;

Revision as of 22:29, 4 December 2007

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.