| 08-10-2002, 07:02 AM | #1 |
Guest | There are two commands. For each Integer A from <value> to <value>, do <action>. and For each Integer B from <value> to <value>, do <action>. What's the difference? I can't make my head wrap around this without being pointed in the right direction.. |
| 08-10-2002, 01:39 PM | #2 |
Guest | Hi!. There shouldn't be difference between A and B loops. However, they are there for a reason. They are in case you want to nest them. It's a classic issue on programming. Imagine you want to do something like this: You have an array of regions, and want to create 1 unit for each player on each region. For each A from 1 to number of players do For each B from 1 to 5 do Create 1 unit for player A in region[b]. There are other ways to do that, but that should be ok. Thus, you have A and B to reference them correctly in the last sentence. If only one For sentence existed, For each A from 1 to number of players do For each A from 1 to 5 do Create 1 unit for player A in region[A]. that would be extremely incorrect, as you can see. In common programming languages, FOR sentences allowed you to use any variable, thus nesting as many fors as you may want. However, in WC3 this is limited. Hope that it helps you. Sorry, I'm not a good teacher :) |
