|
|
Alain <aze### [at] qwertyorg> wrote:
.....
>
> When making nested loops, it's normaly beter to initiate any inner loop
> counter just before it's #while statement.
>
> You initiate your counter first outside the outer loop. Then, you
> reinitiate that counter for the next iteration after the #end of the
> loop and after you increment the outer loop's counter.
>
> The usual way is:
> Initiate the outer loop's counter.
> Start the outer loop.
> possibly do some stuff.
>
> Initiate the iner loop's counter.
> Start the inner loop.
> Do the iner loop's stuf and counter incrementation.
> Close the iner loop.
>
> possibly do some other outer loop stuff.
> Increment the outer loop's counter.
> Close the outer loop.
>
> This is much cleaner as the iner loop is initiated just before the place
> where it's used.
> You only need to initialise the iner loop in one place.
> You can use a #local variable for the iner loop instead of one that is
> global. It reduces the risks of name collision and undesirable side effects.
>
>
>
> Alain
Ah. I don't know why I didn't understand before.
Oh well, better late than never.
Thanks guys,
D103
Post a reply to this message
|
|