Posted: 7th Apr 2004 10:34
Hi all!
This is a simple function I made that lists every folder in the computer, and puts them into the arrays sorted by they're level.
Five levels max: folders1$(lev1),folders2$(lev2),folders3$(lev3), and so on... all the way up to 5. It's pretty hard to explain in detail, but try it and you'll understand. It'll create a file named "files.seph" in C:\, just open it in notepad to see.
dont input levels too high, because its actually just making the arrays larger, and yeah, slow down heaps. Anyways, I've said enough, here's the code...

+ Code Snippet
input "Level 1 Quantity:",l1q:input "Level 2 Quantity:",l2q:input "Level 3 Quantity:",l3q:input "Level 4 Quantity:",l4q:input "Level 5 Quantity:",l5q
folfind(l1q,l2q,l3q,l4q,l5q)
CD "C:\":if file exist("files.seph")=1 then delete file "files.seph"
open to write 1,"files.seph"
for lev1=1 to l1q-1:if folders1$(lev1)<>"" then write string 1,folders1$(lev1)
next lev1
for lev2=1 to l2q-1:if folders2$(lev2)<>"" then write string 1,folders2$(lev2)
next lev2
for lev3=1 to l3q-1:if folders3$(lev3)<>"" then write string 1,folders3$(lev3)
next lev3
for lev4=1 to l4q-1:if folders4$(lev4)<>"" then write string 1,folders4$(lev4)
next lev4
for lev5=1 to l5q-1:if folders5$(lev5)<>"" then write string 1,folders5$(lev5)
next lev5
close file 1

function folfind(lev1qty,lev2qty,lev3qty,lev4qty,lev5qty)
dim folders1$(lev1qty):dim folders2$(lev2qty):dim folders3$(lev3qty):dim folders4$(lev4qty):dim folders5$(lev5qty)
CD "C:\"
lev1fol=1
find first
repeat
   if GET FILE TYPE()=1
      cd Get File Name$():folders1$(lev1fol)=GET DIR$():cd "C:\":lev1fol=lev1fol+1
   endif
   if lev1fol=lev1qty-1 then goto after1
   if GET FILE TYPE()=-1 then levup=1 else find next
until levup=1
after1:
lev2fol=1
curr=1
for curr=1 to lev1fol-1
cd folders1$(curr)
lev2up=0
find first
repeat
   if GET FILE TYPE()=1
      cd Get File Name$():folders2$(lev2fol)=GET DIR$():cd folders1$(curr):lev2fol=lev2fol+1
   endif
   if lev2fol=lev2qty-1 then goto after2
   if GET FILE TYPE()=-1 then lev2up=1 else find next
until lev2up=1
next curr
after2:
lev3fol=1
curr3=1
for curr3=1 to lev2fol-1
cd folders2$(curr3)
lev3up=0
find first
repeat
   if GET FILE TYPE()=1
      cd Get File Name$():folders3$(lev3fol)=GET DIR$():cd folders2$(curr3):lev3fol=lev3fol+1
   endif
   if lev3fol=lev3qty-1 then goto after3
   if GET FILE TYPE()=-1 then lev3up=1 else find next
until lev3up=1
next curr3
after3:
lev4fol=1
curr4=1
for curr4=1 to lev3fol-1
cd folders3$(curr4)
lev4up=0
find first
repeat
   if GET FILE TYPE()=1
      cd Get File Name$():folders4$(lev4fol)=GET DIR$():cd folders3$(curr4):lev4fol=lev4fol+1
   endif
   if lev4fol=lev4qty-1 then goto after4
   if GET FILE TYPE()=-1 then lev4up=1 else find next
until lev4up=1
next curr4
after4:
lev5fol=1
curr5=1
for curr5=1 to lev4fol-1
cd folders4$(curr5)
lev4up=0
find first
repeat
   if GET FILE TYPE()=1
      cd Get File Name$():folders5$(lev5fol)=GET DIR$():cd folders4$(curr5):lev5fol=lev5fol+1
   endif
   if lev5fol=lev5qty-1 then goto after5
   if GET FILE TYPE()=-1 then lev5up=1 else find next
until lev5up=1
next curr5
after5:
endfunction