Ainakin itse olen käyttänyt tätä yhessä musiikkisoittimessa.
Toi on loppujen lopuks aika purkka viritelmä ja ei ehkä se nopein tapa, mut toimii kuiteski.
Code: Select all
Type Kansiot
Field Kansio$
Field Check
EndType
Type Tiedostot //Tähän tyyppiin menee kaikki tiedostojen polut.
Field Files$
EndType
Function Search(Direct$,FileT$="") //direct$=Polku josta haetaan. FileT$=Tiedostopääte Esim. ".Bmp" hakee kaikki ".Bmp"Tiedostot
Repeat
ChDir Direct$
oDirect$=direct$
StartSearch
While loppu=False
file$=FindFile()
If File$="" Then loppu=1
If IsDirectory (File$)
addt$=RemoveChr(CurrentDir()+File$,".")
same=0
For IKansiot.Kansiot = Each Kansiot
If iKansiot\Kansio$=addt$ Then same=1:Exit
Next iKansiot.Kansiot
If same=0
newKansiot.Kansiot=New(Kansiot)
NewKansiot\Kansio$=addt$
EndIf
NewKansiot\Check=0
EndIf
Wend
loppu=0
i=0
For iKansiot.Kansiot = Each Kansiot
If i=0
If iKansiot\Check=0
i+1
iKansiot\Check=1
Direct$=iKansiot\Kansio$+"\"
EndIf
EndIf
Next IKansiot.Kansiot
i=0
EndSearch
If oDirect$=Direct$ Then Exit
Forever
loppu=0
//lisätään tietoa -Tiedostot- tyyppiin
Leng=Len(FileT$)
Repeat
oDirect$=Direct$
i=0
For iKansiot.Kansiot = Each Kansiot
If i=0
Direct$=iKansiot\Kansio$+"\"
iKansiot\Kansio$=0
ChDir direct$
Delete iKansiot
EndIf
i+1
Next iKansiot.Kansiot
If oDirect$=Direct$ Then Exit
StartSearch
While loppu=0
File$=FindFile()
If file$="" Then loppu=1
If Leng>0
If Lower(Right (File$,Leng))=Filet$
newTiedostot.Tiedostot=New(Tiedostot)
NewTiedostot\Files$= CurrentDir()+File$
EndIf
Else
If Not IsDirectory (File$)
newTiedostot.Tiedostot=New(Tiedostot)
newTiedostot\Files$=CurrentDir()+File$
EndIf
EndIf
Wend
EndSearch
Loppu=0
Forever
EndFunction
Function RemoveChr(txt$,r$) //txt$=merkkijono //r$=poistettava merkki
leng=Len(Txt$)-1
lengg=leng
For a=0 to lengg
at$=Left (txt$,1)
If Not at$=r$
ret$=ret$+at$
EndIf
txt$=Right (txt$,leng)
leng-1
Next a
Return ret$
EndFunction