"break" command changed + new "continue" command
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6451 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+31
-17
@@ -554,6 +554,11 @@
|
||||
<argument token="N" description="the amount of loops"/>
|
||||
<argument token="body" description="the body to execute on each iteration"/>
|
||||
</arguments>
|
||||
<references>
|
||||
<identifierReference identifier="break"/>
|
||||
<identifierReference identifier="continue"/>
|
||||
<identifierReference identifier="while"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
<command name="while">
|
||||
@@ -573,34 +578,43 @@
|
||||
<argument token="cond" description="the condition" valueNotes="0 (false) or anything else (true)"/>
|
||||
<argument token="body" description="the body to execute on each iteration"/>
|
||||
</arguments>
|
||||
<references>
|
||||
<identifierReference identifier="break"/>
|
||||
<identifierReference identifier="continue"/>
|
||||
<identifierReference identifier="loop"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
<command name="break">
|
||||
<description>Aborts a loop created with a 'loop' or 'while' command.</description>
|
||||
<remarks>
|
||||
<remark>
|
||||
Note: As opposed to (almost) any other scripting language, this command does NOT abort execution of the current iteration.
|
||||
Instead, it aborts the loop after the execution of that iteration has finished.
|
||||
If you want to break out of a loop without executing the rest of the code, use an if-else construction as in the last example.
|
||||
</remark>
|
||||
</remarks>
|
||||
<examples>
|
||||
<example>
|
||||
<code><![CDATA[loop i 10 [ echo $i; if (= $i 4) break ]]]></code>
|
||||
<explanation>output: 0 1 2 3 4</explanation>
|
||||
</example>
|
||||
<example>
|
||||
<code><![CDATA[loop i 10 [ if (= $i 4) break; echo $i ]]]></code>
|
||||
<explanation>output: 0 1 2 3 4</explanation>
|
||||
<explanation>Note how the result is no different than in the example before.</explanation>
|
||||
</example>
|
||||
<example>
|
||||
<code><![CDATA[loop i 10 [ if (= $i 4) [break] [echo $i] ]]]></code>
|
||||
<code><![CDATA[loop i 10 [ if (= $i 4) [ break ]; echo $i]]]></code>
|
||||
<explanation>output: 0 1 2 3</explanation>
|
||||
</example>
|
||||
</examples>
|
||||
<references>
|
||||
<identifierReference identifier="continue"/>
|
||||
<identifierReference identifier="loop"/>
|
||||
<identifierReference identifier="while"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
<command name="continue">
|
||||
<description>Skip current loop iteration.</description>
|
||||
<examples>
|
||||
<example>
|
||||
<code><![CDATA[loop i 5 [ if (= $i 2) [ continue ]; echo $i]]]></code>
|
||||
<explanation>output: 0 1 3 4</explanation>
|
||||
</example>
|
||||
</examples>
|
||||
<references>
|
||||
<identifierReference identifier="break"/>
|
||||
<identifierReference identifier="loop"/>
|
||||
<identifierReference identifier="while"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
<command name="concat">
|
||||
<description>Concatenates multiple strings with spaces inbetween.</description>
|
||||
<examples>
|
||||
|
||||
Reference in New Issue
Block a user