🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.basic.visual
4 messages
4 total messages Started by Ty Sun, 21 Mar 1999 00:00
Directory Recursion
#161
Author: Ty
Date: Sun, 21 Mar 1999 00:00
25 lines
1802 bytes
What I'm trying to do is do a pre-order directory listing.  However, my sub
prematurely ends at the "Name=Dir" when coming off a pop.  What I'm I doing
wrong? or can you suggest doing this a better way?

Private Sub GetDirInfo(Path)
    Dim Name, Response

    Name = Dir(Path, vbDirectory)
        Do While Name <> ""
            If Name <> "." And Name <> ".." Then
                If (GetAttr(Path & Name) And vbDirectory) = vbDirectory Then
                    Path = Path & Name & "\"
                                    Debug.Print Path

                    GetDirInfo (Path)
                            End If
            End If
            Name = Dir
        Loop
End Sub

--

Thanks.
-ty
Re: Directory Recursion
#162
Author: James Spate
Date: Sun, 21 Mar 1999 00:00
37 lines
1809 bytes
Pet hates...

When you declare any variable declare it explicitly,

Private Sub GetDirInfo(Path as String)
    'OK declareing multiple variable on on line is a pet hate
    Dim Name as String, Response as String


Another pet hate, use Dir$, Format$, Left$, etc$ when your working with
strings, they work faster when you compile the program.

Anyhow,

Private Sub GetDirInfo(Path as String)
Dim strDirName as string

    'Get the first directory
    strDirName = Dir$(Path, vbDirectory)

    Do Until strTemp=""

        If strDirName <> "." And strDirName <> ".." Then
            If (GetAttr(Path & strDirName) And vbDirectory) = vbDirectory
Then
                Path = Path & strDirName & "\"

                Debug.Print Path

                GetDirInfo (Path)
            End If
        End If
        Name = Dir$()
    Loop

End Sub
Re: Directory Recursion
#165
Author: Andy Robinson
Date: Fri, 26 Mar 1999 00:00
16 lines
1530 bytes
Ty wrote in message ...
>What I'm trying to do is do a pre-order directory listing.  However, my sub
>prematurely ends at the "Name=Dir" when coming off a pop.  What I'm I doing
>wrong? or can you suggest doing this a better way?


This is probably a repeat of an earlier message - in VB6 you can use the
FileSysObject from VBScript (see help for details) which contains
collections of folders and files for doing this kind of stuff.  You need a
Reference in your project to the relevant .dll which is.... Microsoft
Scripting Runtime

Cheers

Andy
Re: Directory Recursion
#166
Author: Josef Haselberger
Date: Mon, 29 Mar 1999 00:00
116 lines
4750 bytes
I use a home mage DLL 32Bit for this task
you can find it at
http://www.geocities.com/SiliconValley/Sector/8404/archiv/docinfo.zip
(46k)

BAS File Header 
and Coding Example follows..

Private Sub PopulateDir2(ByVal n As Node, ByVal d As String, ByVal
ebene As Integer)
Dim myName As String * 100
Dim mNode1 As Node
Dim hDir As Long
Dim x, s As String
Dim flags As Integer

    x = ""
    flags = DIR_SUBDIR
    hDir = GetDirFirst(d + "\*.*", flags, myName, 99)
    s = alltrim(myName)
    While s <> ""
        If s <> "." And s <> ".." Then
            '--- Verzeichnise einf�gen
            Set mNode1 = tvwDB.Nodes.Add(n.Key, tvwChild, d + "\" + s,
s, "geschlossen")
            mNode1.ExpandedImage = "ge�ffnet"
            If ebene < 2 Then
                mNode1.Expanded = True
            End If
            If ebene = 1 Then
                Progress.Value = i
            End If
            '--- Tiefergelegene Verzeichnisse eintragen
            PopulateDir2 mNode1, d + "\" + s, ebene + 1
        End If
        flags = DIR_SUBDIR
        If GetDirNext(hDir, flags, myName, 99) Then
            s = alltrim(myName)
        Else
            s = ""
        End If
    Wend
End Sub

-- Ratzefumm@gmx.net

'-----------------------------------------
' Headerdatei zu DOKINFO.DLL
' (c) Hasitech 98
' Letzte �nderung:
' 25.2.98 Flags aus DIR-Funktionen zur�ckgeben eingebaut.
'-----------------------------------------
Global Const DIR_ARCHIV = 32
Global Const DIR_HIDDEN = 2
Global Const DIR_NORMAL = 0
Global Const DIR_RDONLY = 1
Global Const DIR_SUBDIR = 16
Global Const DIR_SYSTEM = 4

Declare Function GetPDFDocInfo Lib "docinfo.dll" (ByVal Pfad As
String, ByVal tag As String, ByVal res As String) As Integer
Declare Function GetVolLable Lib "docinfo.dll" (ByVal Pfad As String,
ByVal lable As String, ByVal syslable As String) As Integer

' GetDirFirst(pfad,nFlags, Name, Maxlen)
' pfad="c:\*.*"
' Flags: 32=Archiv, 2=Hidden, 0=Normal, 1=RDOnly,
'        16=Subdir, 4=Systemfile
' Receivevariable Name enth�lt den gefundenen Namen "FILENAM.NAM"
' Maximall�nge des Receivestrings
' Returnwert ist der Handle auf die Suchstruktur, n�tig f�r GetDirNext
Declare Function GetDirFirst Lib "docinfo.dll" (ByVal Path As String,
ByRef flags As Integer, ByVal Name As String, ByVal Maxlen As Integer)
As Long

' hDir ist der Returnwert (LONG) aus dem GetDirFirst Aufruf
' Flags: 32=Archiv, 2=Hidden, 0=Normal, 1=RDOnly,
'        16=Subdir, 4=Systemfile
' Receivevariable Name enth�lt den gefundenen Namen "FILENAM.NAM"
' Maximall�nge des Receivestrings
' Returnwert ist der Handle auf die Suchstruktur, n�tig f�r GetDirNext
Declare Function GetDirNext Lib "docinfo.dll" (ByVal hDir As Long,
ByRef nFlags As Integer, ByVal Name As String, ByVal Maxlen As
Integer) As Long



"Ty" <tya@home.com> wrote:

>What I'm trying to do is do a pre-order directory listing.  However, my sub
>prematurely ends at the "Name=Dir" when coming off a pop.  What I'm I doing
>wrong? or can you suggest doing this a better way?
>
>Private Sub GetDirInfo(Path)
>    Dim Name, Response
>
>    Name = Dir(Path, vbDirectory)
>        Do While Name <> ""
>            If Name <> "." And Name <> ".." Then
>                If (GetAttr(Path & Name) And vbDirectory) = vbDirectory Then
>                    Path = Path & Name & "\"
>                                    Debug.Print Path
>
>                    GetDirInfo (Path)
>                            End If
>            End If
>            Name = Dir
>        Loop
>End Sub
>
>--
>
>Thanks.
>-ty
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads