Avatar billede reds2001 Nybegynder
20. december 2001 - 20:23 Der er 1 kommentar og
1 løsning

Forklaring af kode!!

Jeg har opsnuset en kodestump der gennemløber mine filerne på computeren men er der nogen der kan gennemgå den så jeg kan forstå den:

Public Sub DirWalk(ByVal sPattern As String, ByVal CurrDir As String)
If IsRunning = False Then Exit Sub
   
    Select Case (Right$(CurrDir, 1) <> \"\\\")
        Case True:  Dir1.Path = CurrDir & \"\\\"
        Case False: Dir1.Path = CurrDir
    End Select
   
    lblCurrPath.Caption = \"Searching: \" & CurrDir
   
    For I = 0 To Dir1.ListCount
        If Dir1.List(I) <> \"\" Then
            DoEvents
            Call DirWalk(sPattern, Dir1.List(I))
        Else
            Select Case (Right$(Dir1.Path, 1) = \"\\\")
                Case True:  sCurrPath = Left(Dir1.Path, Len(Dir1.Path) - 1)
                Case False: sCurrPath = Dir1.Path
            End Select
           
            File1.Path = sCurrPath
            File1.Pattern = sPattern
           
            If IsRunning = False Then Exit Sub
           
            If File1.ListCount > 0 Then
                For ii = 0 To File1.ListCount - 1
                    strFile = sCurrPath & \"\\\" & File1.List(ii)
                    lstFound.AddItem strFile
                   
                    If WriteLogFile And IsRunning Then Print #1, strFile
                    If DeleteFiles = True Then Kill strFile
                   
                    lblInfo.Caption = \"Files found (\" & lstFound.ListCount & \"):\"
                Next
            End If
           
            iLen = InStrRev(Dir1.Path, \"\\\")
           
            Dir1.Path = Mid(Dir1.Path, 1, iLen)
        End If
       
        If IsRunning = False Then Exit Sub
    Next
   
    If IsRunning = False Then Exit Sub
End Sub
Avatar billede terry Ekspert
20. december 2001 - 20:29 #1
well it would take a bit to explain, I can see that its using a recursive call to travers down the list. Recursive call is that the function calls its self.
Avatar billede reds2001 Nybegynder
18. januar 2002 - 10:12 #2
jeg lukker
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester