home *** CD-ROM | disk | FTP | other *** search
Visual Basic class definition | 2000-01-30 | 2.7 KB | 111 lines |
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "Catalogue"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
- Attribute VB_Ext_KEY = "Member0" ,"FileNames"
- Attribute VB_Ext_KEY = "Member1" ,"Generations"
- Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
- Option Explicit
- Private genlist As Collection
- Private t As Token
- Private catFileName As String
- 'adds a generation to the catalogue
- Public Sub Add(nlist As BNodeList)
-
- genlist.Add nlist
-
- End Sub
- ' helper routine for ReadCatalogue
- Private Function ReadCatalogue1(t As Token, p As BNode) As BNodeList
- Dim list As New BNodeList, n As BNode, curDirLevel As Integer
- Dim curGeneration As Integer
-
- curDirLevel = t.dirLevel
- curGeneration = t.generation
-
- Do While Not t.tEOF
- If curGeneration <> t.generation Then
- Exit Do
- ElseIf t.dirLevel < curDirLevel Then
- Exit Do
- ElseIf t.dirLevel > curDirLevel Then
- Set n.nextBNode = ReadCatalogue1(t, n)
- Else ' just a normal node
- Call list.Add(t.fileName, t.attributes, Nothing, t.fileName)
- Set n = list(t.fileName)
- Set n.prevBNode = p
- t.GetNext
- End If
- Loop
-
- Set ReadCatalogue1 = list
-
- End Function
- Public Sub ReadCatalogue(fn As String)
- Dim nl As BNodeList
- '
- ' this is where we initialize everything
- '
- catFileName = fn
- Set genlist = New Collection
- Set t = New Token
-
- On Error GoTo new_cat
- t.Start (fn)
- 'read the catalogue in
- Do While Not t.tEOF
- Set nl = ReadCatalogue1(t, Nothing)
- genlist.Add nl
- Loop
- Exit Sub
-
- new_cat:
-
-
- End Sub
- 'writes the catalogue to file
- Public Sub WriteCatalogue()
- Dim g As BNodeList
- Dim gc As Integer, filenum As Integer
-
- Set t = Nothing
- filenum = FreeFile
- Open catFileName For Output As #filenum
- gc = 0
- For Each g In genlist
- Call WriteCatalogue1(g, filenum, gc, 0)
- gc = gc + 1
- Next
- Close #filenum
-
- End Sub
- 'helper routine for WriteCatalogue
- Private Sub WriteCatalogue1(nlist As BNodeList, filenum As Integer, generation As Integer, dirLevel As Integer)
- Dim n As BNode, p As BNodeList, dirFlag As Boolean
-
- For Each n In nlist
- Set p = n.nextBNode
- dirFlag = Not p Is Nothing
- If dirFlag Then
- Write #filenum, generation, dirLevel, n.attributes, n.fileName, dirFlag
- Call WriteCatalogue1(p, filenum, generation, dirLevel + 1)
- Else
- Write #filenum, generation, dirLevel, n.attributes, n.fileName, dirFlag
- End If
- Next
-
- End Sub
-
-
-
-