| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
infinite loop...but where?
this code is excerpted from an asp script I'm writing for a shopping-cart system on a web site. the database of items is in a file on the server. the problem is that I can add any one item, and as many of that one item as I want. but when I add two different items and or any amount of either at the same time, and submit, this code gets stuck in an infinite loop.
this part of the code is the part that submits the data. EDIT: sorry for the bad formatting, the forums did that. EDIT: nevermind! Its working now...but I dont know what it was! how lucky, eh? Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 'Instantiate the FileSystemObject Set TS = objFSO.OpenTextFile(strFileName, 1, False) 'use Opentextfile Method to Open the text File noredun = 0 totPrice = 0 allNum = 0 do while cart.count <> 0 c = 0 dontCheck = false quan = 0 Do While cart.count > c if dontCheck = false then ProdNum = TS.ReadLine 'get product number ProdName = TS.ReadLine 'get name of product ProdPrice = TS.ReadLine 'get product price end if if ProdNum = tmpItems(c) then 'found one totPrice = totPrice + ProdPrice if quan = 0 then noredun = noredun + 1 'keep track of how many DIFFERENT items we have found (not including redundancies) allNum = allNum + 1 quan = quan + 1 'keep track of how many items we have found ALL together for this specific item (including redundancies) dontCheck = true 'we also need to not read in any more from the database until we've checked the rest of the cart list for redundancies of this item k = Cart.Keys 'reset this variable because we are about to use it Cart.Remove trim(k(c)) 'remove it from the cart tmpItems = Cart.Items 'reset this variable because we removed an item else if dontCheck = true then c = c + 1 'found one once before. keep moving up the list end if Loop MailMessage = MailMessage & "Qty:" & quan & " " & ProdNum & " " & ProdPrice & " " & ProdName & linebr TS.close 'reset the file for reading if cart.count < 1 then exit do Set TS = objFSO.OpenTextFile(strFileName, 1, False) loop |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > infinite loop...but where? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|