|
-
Sep 30th, 2004, 11:05 PM
#1
Thread Starter
Fanatic Member
While loops not behaving
Heres the PCode for a function
Code:
while(!file.EOF)
{
:1
while(!file.EOF)
{
:2
file.MoveNext();
}
:3
}
file.close();
Here is what im doing. I'm pulling things from a recordset... everything works fine, except, when the second loop hits a EOF.
This prints everything out that I want it to, it returns everything to the browser i want to, but, when the second loop hits an EOF it exits and stops loading my page.
Initialy I thought when the second loop hit EOF it was also exiting the first loop. But that is not the case. To me, it looks as if some kind of an error is happening when it hits EOF and stops loading my page. Yes, that must be it, because the bottom section of the interface is also cut off.. meaning no other ASP or HTML is executed. I know this is some kind of EOF problem because it ALWAYS happens with the last recordset (or last product in the table). When the last product is hit, it prints everything inside of that loop, then exits, and stops loading everything else. So the error is happening when the loop terminates?
As to what this error is I have no idea. This ever happen to anyone?
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Sep 30th, 2004, 11:14 PM
#2
Thread Starter
Fanatic Member
Code:
//objProducts is defined up here
while(!objProducts.EOF)
{
intQuantity = objProducts('intQuantity').value;
pCycleGuid = objProducts('guidProductID');
while (pCycleGuid == objProducts('guidProductID') && !objProducts.EOF)
{
//do stuff here
pCycleGuid = objProducts('guidProductID').value;
objProducts.MoveNext();
}
//on EOF, the second loop breaks here
//and does not execute this portion
}
objProducts.close();
//allthough im not sure if its actually closing since it never reaches
//this part down here.
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Sep 30th, 2004, 11:23 PM
#3
Thread Starter
Fanatic Member
Wow... I just fixed the problem. This is the wierdest solution yet...
Code:
while ((!objProducts.EOF) && (pCycleGuid == objProducts('guidProductID').value) )
I just switched the while loop around. Anyone konw why that worked?
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Oct 1st, 2004, 04:31 AM
#4
No idea...
As to the leaving.. once you moved to the last record the eof flag is set.
If you need to loop for display purpose, I personally open as static and then loop with a counter (you can get the number of records returned via rst.recordcount) so you don't miss any records.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|