I have written a piece of asp code that should put unique file extensions into an array. So for example if a db has the files:
workdocument.txt
myspread.xsl
game.exe
adobe.exe
then the following piece of code should only put .txt, .xsl, .exe into the array. In otherwords if there are 10 exe files, it will only put one instance of that extension into the array once.
my code looks like this:
-----------------------------------------------
rsFiles.MoveFirst
While not rsFiles.EOF
file = rsFiles("FileName"
rtn = InStr(1,file, "."
if rtn > 0 then
extension = Right(file, (Len(file)-rtn+1))
end if
for l=0 to 49
if extArray(arrayinc) = extension then
exit for
else
extArray(arrayinc) = extension
Response.write extArray(arrayinc) & "<br>"
arrayinc= arrayinc+1
exit for
end if
next
rsFiles.MoveNext
wend
----------------------------------------------------
the problem is this code puts in all the extensions (even duplicates extensions )into the array. It looks as though it should work but I can't figure out whats wrong, grateful for any help. Thanks.
workdocument.txt
myspread.xsl
game.exe
adobe.exe
then the following piece of code should only put .txt, .xsl, .exe into the array. In otherwords if there are 10 exe files, it will only put one instance of that extension into the array once.
my code looks like this:
-----------------------------------------------
rsFiles.MoveFirst
While not rsFiles.EOF
file = rsFiles("FileName"
rtn = InStr(1,file, "."
if rtn > 0 then
extension = Right(file, (Len(file)-rtn+1))
end if
for l=0 to 49
if extArray(arrayinc) = extension then
exit for
else
extArray(arrayinc) = extension
Response.write extArray(arrayinc) & "<br>"
arrayinc= arrayinc+1
exit for
end if
next
rsFiles.MoveNext
wend
----------------------------------------------------
the problem is this code puts in all the extensions (even duplicates extensions )into the array. It looks as though it should work but I can't figure out whats wrong, grateful for any help. Thanks.