first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

Code: Scanning A Root for Files and Directories with Scripting and rasxADO

Private Sub basFavoritesScan(ByRef objADO As rasxADO.ADOServices, _ Optional ByVal Directory = "\\")

Dim objFolders As Scripting.Folders
Dim objFolder As Scripting.Folder
Dim objFiles As Scripting.Files
Dim objFile As Scripting.File

Dim lngFolderCount As Long

Dim varParameters(0 To 1, 0 To 1) As Variant
'To be a two-dimensional array of form:
'   <param' name>, <row 0>
'   <param' value>, <row 0>
'   <param' name>, <row 1>
'   <param' value>, <row 1>
'etc.

'For readability:
varParameters(0, 0) = "@path"
varParameters(1, 0) = vbNullString

varParameters(0, 1) = "@url"
varParameters(1, 1) = vbNullString

On Error GoTo basFavoritesScan_Err

p_strInFile = basGetKeyString("path_root_favorites") & Directory
Set objFolders = p_objFileSys.GetFolder(p_strInFile).SubFolders

'Initialize Progress Bar.
Call basProgress(0, 0, objFolders.Count): p_lngStatusCount = 0

For Each objFolder In objFolders

    varParameters(1, 0) = Directory & objFolder.Name
    varParameters(1, 1) = "Directory"
    If Not objADO.StoredProcCmd("NewFavorite", varParameters, True) Then GoTo basFavoritesScan_Err
    
    Set objFiles = objFolder.Files
    For Each objFile In objFiles
        varParameters(1, 0) = Directory & objFolder.Name & "\\" & objFile.Name
        varParameters(1, 1) = "File"
        If Not objADO.StoredProcCmd("NewFavorite", varParameters, True) Then GoTo basFavoritesScan_Err
    Next
    
    'Mark progress.
    p_lngStatusCount = p_lngStatusCount + 1: Call basProgress(p_lngStatusCount)

Next

'Terminate Progress Bar.
Call basProgress(0): p_lngStatusCount = 0

basFavoritesScan_Exit: Exit Sub

basFavoritesScan_Err: If (VBA.Err.Number <> 0) Or (p_objADO.Connection.Errors.Count > 0) Then Call Me.basDataErrMsg(p_objADO, "basFavorites()") If (VBA.Err.Number <> 0) Then Resume basFavoritesScan_Exit Else GoTo basFavoritesScan_Exit End If End If End Sub

mod date: 2002-01-15T09:10:49.000Z