mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 10:00:42 +01:00
103 lines
2.1 KiB
XML
103 lines
2.1 KiB
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<root>
|
|
<name>for()</name>
|
|
|
|
<category>Control</category>
|
|
|
|
<subcategory>Iteration</subcategory>
|
|
|
|
<usage>Web & Application</usage>
|
|
|
|
<example>
|
|
<image>for_.gif</image>
|
|
<applet></applet>
|
|
<code>
|
|
for(int i=0; i<40; i=i+1) {
|
|
line(30, i, 80, i);
|
|
}
|
|
</code>
|
|
</example>
|
|
|
|
<example>
|
|
<image>for_2.gif</image>
|
|
<applet></applet>
|
|
<code>
|
|
for(int i=0; i<80; i=i+5) {
|
|
line(30, i, 80, i);
|
|
}
|
|
</code>
|
|
</example>
|
|
|
|
<example>
|
|
<image>for_3.gif</image>
|
|
<applet></applet>
|
|
<code>
|
|
for(int i=40; i<80; i=i+5) {
|
|
line(30, i, 80, i);
|
|
}
|
|
</code>
|
|
</example>
|
|
|
|
<example>
|
|
<image>for_4.gif</image>
|
|
<applet></applet>
|
|
<code>
|
|
for(int i=30; i<80; i=i+5) {
|
|
for(int j=0; j<80; j=j+5) {
|
|
point(i, j);
|
|
}
|
|
}
|
|
</code>
|
|
</example>
|
|
|
|
<description>
|
|
Controls a sequence of repetitions. A <b>for()</b> structure has three parts: <b>init</b>, <b>test</b>, and <b>update</b>. Each part must be separated by a semi-colon ";". The loop continues until the test evaluates to <b>false</b>. When a <b>for()</b> structure is executed, the following sequence of events occurs:<br />1. The init statement is executed<br />2. The test is evaluated to be true or false<br />3. If the test is true, jump to step 4. If the test is False, jump to step 6<br />4. Execute the statements within the block<br />5. Execute the update statement and jump to step 2<br />6. Exit the loop.
|
|
</description>
|
|
|
|
<syntax>
|
|
for(<c>init</c>; <c>test</c>; <c>update</c>) {
|
|
<c>statements</c>
|
|
}
|
|
</syntax>
|
|
|
|
<parameter>
|
|
<label>init</label>
|
|
<description>statement executed once when beginning loop</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>test</label>
|
|
<description>if the test evaluates to <b>true</b>, the statements execute</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>update</label>
|
|
<description>executes at the end of each iteration</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>statements</label>
|
|
<description>collection of statements executed each time through the loop</description>
|
|
</parameter>
|
|
|
|
<returns></returns>
|
|
|
|
<related>
|
|
while()
|
|
</related>
|
|
|
|
<availability>1.0</availability>
|
|
|
|
<type>Structure</type>
|
|
|
|
<partof>PDE</partof>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</root>
|