We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › exception in the for() structure
Page Index Toggle Pages: 1
exception in the for() structure (Read 757 times)
exception in the for() structure
Sep 17th, 2007, 11:36pm
 
hello.
I want to do an exception in the for structure. a have a number of lines displayed as a spectrum for the microfone, and i want to do things to just of of the lines. how can selectively pick out one of these lines and modify it?

Slm
Re: exception in the for() structure
Reply #1 - Sep 18th, 2007, 8:59pm
 
Hey,
try using the modulo (%) to check the value you're at.
If the modulo = 0, then it means that you're at a specific value and that you want to run something special.
Copy paste the code below, and look oat the output window.
I just used random numbers, change it for yours.

-------------------------
void setup() {
 size(200,200);
 background(0);
 noLoop();
}

void draw() {
for (int i=0; i<14; i++) {
 if (i%5 == 0) {
   println("Do something special");
 }
 else {
  println("Do something");
 }
}
}

-------------------------

Cheers
Steven
Page Index Toggle Pages: 1