[thelist] Looping Psuedocode
Rob Smith
rob.smith at THERMON.com
Thu Aug 28 10:32:33 CDT 2003
Hmm.. I thought this would be a simple.
Ok, these are numbers. I cannot use the DISTINCT because I still need to
reference my original information of all the "Items" (RecordSet). I just
need to hide the duplicates or non-unique values until later.
This is what I was going after..
<%
dim oldArray()
dim rcount
rcount = -1
prodResult.movefirst
while not prodResult.eof
rcount = rcount + 1
redim preserve oldArray(rcount)
oldArray(rcount) =
prodResult.fields.item("ProductFamily").value
prodResult.movenext
wend
dim newArray()
eCount = -1
for each oldElement in oldArray
eCount = eCount + 1
redim preserve newArray(eCount)
uniqueElement = true
for each newElement in newArray
if newElement = oldElement then
uniqueElement = false
exit for
end if
next
if uniqueElement then
newArray(eCount) = oldElement
else
eCount = eCount - 1
end if
next
'for x = 0 to eCount
' oldArray (x) = newArray(x)
'next
for x = 0 to ubound(newArray)-1
if newArray(x) = family then
response.write("<a href=""get_stock.asp?family=" &
newArray(x) & """><img src=""grfx/minus.gif"" border=""0"">" & newArray(x) &
"</a><br>")
else
response.write("<a href=""get_stock.asp?family=" &
newArray(x) & """><img src=""grfx/plus.gif"" border=""0"">" & newArray(x) &
"</a><br>")
end if
if newArray(x) = family then
while not prodFamily.eof
response.write("<a
href=""inventory_stock.asp?partID=" & prodFamily.fields.item("Part").value &
"""><img src=""grfx/sub.gif"" border=""0"">" &
prodFamily.fields.item("Description").value & "</a><br>")
prodFamily.movenext
wend
end if
next
%>
and it does what I need it to do which is:
original data:
Show A Show A Show A
Show A_1 to Show B then Show A_1
Show A_2 Show C once Show A_2
Show A_3 clicked Show A_3
Show B A Show B
Show B_1 Show C
Show B_2
Show B_3
Show C
Show C_1
Show C_2
Show C_3
So if anyone can use this later, feel free to.
Rob.Smith
More information about the thelist
mailing list