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 › what does this code means
Page Index Toggle Pages: 1
what does this code means? (Read 317 times)
what does this code means?
Feb 22nd, 2010, 5:22am
 
Hello i found a code, and there is a line in the code i havent seen before, can anybody tell me what does it means?

here is the line:
for(int i = 0 , b = 1 + int(random(wordLength)); i < b ; i++){


and here is all the code

Code:


String[] myLetters = { "a", "b","c","d","e","f", "g","h","i","j", "k", "l","m","n","o","p", "q","r","s","t" };
String word;
int wordLength = 244;

void Setup(){
size(200,200);
}
void draw(){
}

void mousePressed(){
word = "";
for(int i = 0 , b = 1 + int(random(wordLength)); i < b ; i++){
word=word+myLetters[int(random(myLetters.length))];
}
println(" " + word);
}



Re: what does this code means?
Reply #1 - Feb 22nd, 2010, 5:43am
 
It's the same as :
Code:
int b = 1 + int(random(wordLength);
for(int i = 0; i < b ; i++) {
 ...
}


or

Code:
int b = 1 + int(random(wordLength);
int i = 0;
while(i < b) {
 ...
 i++;
}


http://processing.org/reference/for.html
http://processing.org/reference/while.html
Page Index Toggle Pages: 1