I have the code below recursively adding all files from a source folder and
then a target folder to two corresponding listboxes. What is happening is
that when there are more than 16 root level items (folders, individual files
or bundles) missing in the target as from the source, I get a nilObject at
this line:

 TargetName = TargetFolder.trueitem(indexT).DisplayName

At first I thought it was because I was using the same variable names both
loops, so I changed the variables from, i.e., "index" for both to "indexT",
etc. for the second loop. This didn't help. It still fails at 17 items
missing in the target.

I then tried placing the SelectFolder() code for the Target just before it's
while...wend, instead of at the top. That also does not change the result.

It never seems to fail, BTW, with the source loop. Since they *should* be
independent of each other, I don't really understand why there should be any
difference in the way they run, particularly one based on the difference
between the two folders.

   dim folders(-1), sourceFolder as FolderItem
   dim currentFolder, itemInFolder as FolderItem
   dim index as integer

   dim foldersT(-1), TargetFolder as FolderItem
   dim currentFolderT, itemInFolderT as FolderItem
   dim indexT as integer

  //get the folders
  sourceFolder = SelectFolder()
  if sourceFolder = nil then return
  
  
  targetFolder = SelectFolder()
  if targetFolder = nil then return
  

  //add files from Source

  // Add rootFolder to stack
  folders.Append sourceFolder
  
  // For each folder in the stack
  while UBound(Folders) > -1
    // Get the folder at the top of the stack
    currentFolder = folders.Pop
    
    // For each item in the current folder
    for index = currentFolder.Count DownTo 1
      itemInFolder = currentFolder.trueitem(index)
      if itemInFolder <> nil then
        
        // If item is a folder
        if itemInFolder.Directory = true then
          // Add folder to the stack
          folders.Append itemInFolder
          
        else
          // Add file to the listbox
          sourceName = sourceFolder.trueitem(index).DisplayName
          sourcePath = sourceFolder.trueitem(index).shellPath
          SourceList.AddRow itemInFolder.DisplayName
          sourceDict.Value(sourceName) = sourcePath

        end if
      end if
    next
  wend


  //add files from Target
 
  /  // Add rootFolder to stack
  foldersT.Append targetFolder
  
  // For each folder in the stack
  while UBound(FoldersT) > -1
    // Get the folder at the top of the stack
    currentFolderT = foldersT.Pop
    
    // For each item in the current folder
    for indexT = currentFolderT.Count DownTo 1
      itemInFolderT = currentFolderT.trueitem(indexT)
      if itemInFolderT <> nil then
        
        // If item is a folder
        if itemInFolderT.Directory = true then
          // Add folder to the stack
          foldersT.Append itemInFolderT
          
        else
          // Add file to the listbox
          TargetName = TargetFolder.trueitem(indexT).DisplayName//*nilObject
reported here
          TargetPath = TargetFolder.trueitem(indexT).shellPath
          TargetList.AddRow itemInFolderT.DisplayName
          TargetDict.Value(TargetName) = TargetPath

        end if
      end if
    next
  wend


All My Best,
Jeffrey

  


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to