Questionable Loops

1. Senior Member
Join Date
Dec 1969
Posts
733

## Questionable Loops

I&#039;ve got a nested loop that is falling out of sequence..<BR>I should get 3 * 8 * 60 responses.. and they should be ordered:<BR>1,1,1-60<BR>1,2,1-60<BR>... etc<BR>instead they order<BR>1,1,1-41<BR>1,2,42-60<BR>1,3,1-60<BR>1,4,1-41<BR>1,5,42-60<BR>...<BR><BR>If I omit the call to the function and just show loop progress, then all is well.. i get the order and total count.. what&#039;s buggin me is that the DO WHILE-LOOP seems to be advancing my FOR-Next loop as well..<BR><BR>Any insight would be very welcome<BR><BR> - - - <BR> Micke<BR><BR>&#039;############################### ##########<BR>&#039;### The code(ish)<BR><BR>FUNCTION SomeFunction()<BR> DO WHILE N &#060; 4<BR> N = N + 1<BR> LOOP<BR>END FUNCTION<BR><BR><BR>FOR iLOB = 1 TO 3<BR> FOR iIVR = 1 To 8<BR> FOR iTopic = 1 TO 60<BR> SomeFunction<BR> response.write "<BR>"& iLOB * iIVR * iTopic<BR> NEXT<BR> NEXT<BR>NEXT<BR>

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Show *ACTUAL* code...

Almost surely the problem is that you haven&#039;t "scoped" your variables, so that the function is using some of the same variables as are the loops. In particular, it looks like you are double-using iLVR.<BR><BR>*PROBABLY* all you need to do is DIM the variables used by the function *IN* the function.<BR><BR>But without actual code, who can tell?<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•