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 › I am a newbie ...
Page Index Toggle Pages: 1
I am a newbie ... (Read 214 times)
I am a newbie ...
Nov 12th, 2008, 6:58pm
 
i been working with the getting started stuff and it works extremely well for me.

I just want to know what does the ----i--- means here:


String lines [] = loadStrings("Glosario Processing. txt");
println("there are" + lines.length + "lines");
for (int i=0; i < lines.length; i++) {
 println(lines[i]);
}

i´ve been checking a lot of examples and most of them comes with the .... for (int i=0; ...... etc ... } appears ...

The text is printed in the console right?
not in the window...??

Thanks for your time and cheers from México to all processing crew and fans all over the world ...
Re: I am a newbie ...
Reply #1 - Nov 13th, 2008, 12:52am
 
Hey, and welcome to the Processing family Smiley

the 'i' is simply a commonly used variable.
in this setting you could call it 'lineNumber', it would still do the same job.
The for(int i= 0; etc is what you call a for loop

The basic structure is something like this.
for(initial variable(s); continue if this expression is true; do this for each increment){
}

so for(int i = 0; i < lines.length; i++){
println(lines[i]);
}

starts off by making a variable, 'i'.
it then says; as long as i is less than (<) the length of lines, print the line (lines[i])
at the end of each loop, it increments i with one (i++, same as i = i + 1 )

hope that answers some of your questions Smiley

-seltar
Page Index Toggle Pages: 1