#### Archived

This topic is now archived and is closed to further replies.

# What does this mean?

This topic is 6586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Apparently the BB attempted to read the less than and greater than signs in your post as html markers.

Please try again, giving your < and > better spacing, and see if it works...

As for what a "for" loop does...

It first assigns your variable to the first thing you give it, so your variable starts at zero. The second parameter tells it how long to increment by checking whether or not the statement is true, so it will increment until the second thing is false. The third parameter generally tells it how much to increment by, for instance, an x++ would increment by one, while x+=10 would increment by ten, every time you go through the for loop. You may also increment by another variable, but be careful not to increment overall by zero or you will probably have an infinite loop on your hands. It will repeat the code after the for statement, either a single line or a bunch of code in {'s, until the second parameter is false.

-fel

[This message has been edited by felisandria (edited December 07, 1999).]

##### Share on other sites
Oh great...
for (render_it_y = 0; render_it_y "<" num_y_tiles; render_it_y++ )

##### Share on other sites
I looked at the HTML source, and I can see what you typed in. I'll try to put it in a code block.

code:
for (render_it_y = 0; render_it_y < num_y_tiles; render_it_y++)

That's a for loop in C. It breaks down into 3 parts (separated by ;'s).

The first part is initialization. In this case, render_it_y is set to 0.

The second part is the condition expression. This expression just tests to see if we should continue looping, even on the first iteration. In this case, the loop will continue as long as render_it_y is less than num_y_tiles.

The third part is the loop expression. This expression is evaluated at the end of each iteration. In this example, it increments the value of render_it_y by 1 (that's what ++ does to a variable, that's why it's called C++ BTW...).

The BASIC equivalent (in case you know BASIC) of this would be:

code:
For render_it_y = 0 to num_y_tiles - 1   ' Whatever code goes here...Next render_it_y

[This message has been edited by Kentamanos (edited December 07, 1999).]