Language \ Environment \ Comparison
 
Index
 
  The Processing 1.0 _ALPHA_ Reference is a work in progress.
If you see any errors or have any comments, please write to: reas at groupc.net
Name  

for()

   
Examples  
for(int i=0; i<40; i=i+1) { 
  line(30, i, 80, i); 
} 
for(int i=0; i<80; i=i+5) { 
  line(30, i, 80, i); 
} 
for(int i=40; i<80; i=i+5) { 
  line(30, i, 80, i); 
} 
for(int i=30; i<80; i=i+5) { 
  for(int j=0; j<80; j=j+5) { 
    point(i, j); 
  } 
} 
Description   Controls a sequence of repetitions. A for() structure has three parts: init, test, and update. Each part must be separated by a semi-colon ";". The loop continues until the test evaluates to false. When a for() structure is executed, the following sequence of events occurs:
1. The init statement is executed
2. The test is evaluated to be true or false
3. If the test is true, jump to step 4. If the test is False, jump to step 6
4. Execute the statements within the block
5. Execute the update statement and jump to step 2
6. Exit the loop.
   
Syntax  
for(init; test; update) { 
  statements
} 
   
Parameters  
init   statement executed once when beginning loop

test   if the test evaluates to true, the statements execute

update   executes at the end of each iteration

statements   collection of statements executed each time through the loop

   
Usage   Web & Application
   
Related   while()
   
© 2004 - 2001 Massachusetts Institute of Technology and Interaction Design Institute Ivrea
Processing is an open project initiated by Ben Fry and Casey Reas