Action event of a PushButton:

  Dim sourceDictCnt as Integer
  Dim targetDictCnt as Integer
  Dim i, h as Integer
  
  If SourceDictionary.Count > 0 then
    sourceDictCnt = SourceDictionary.Count - 1
    
    For i = 0 to sourceDictCnt
      If not TargetDictionary.HasKey(SourceDictionary.Key(i)) then
        ListBox1.AddRow SourceDictionary.Key(i)
      End If
    Next
  End If
  
  If TargetDictionary.Count > 0 then
    targetDictCnt = TargetDictionary.Count - 1
    
    For h = 0 to targetDictCnt
      If not SourceDictionary.HasKey(TargetDictionary.Key(h)) then
        ListBox2.AddRow TargetDictionary.Key(h)
      End If
    Next
  End If


Your main code (the code that parses the directories) could add the path and
file names as Value and Key pairs to the two dictionaries as it populates
the two lists.

  Dim i, sourceCount, targetCount as Integer
  Dim sourceName, sourcePath as String
  Dim targetName, targetPath as String
  Dim sourceFolder, targetFolder as FolderItem
  Dim sourceDict as New Dictionary
  Dim targetDict as New Dictionary
  
// These are the source and target folders of the test I did.
// They would be the two volumes that you are comparing using
// your code.  This code is worthless to you for anything more
// than a test and as an example of how to place your volume
// data into two dictionaries for comparison later in the code
// above.
// sourceCount and targetCount are the number of files in the
// test folders.  Since you will be using recursion, you would
// have to get this count in a different way.  Every time an
// element is added to a Dictionary, increment a counter.
  sourceFolder = DesktopFolder.Child("Test").Child("Source")
  sourceCount = sourceFolder.Count
  
  targetFolder = DesktopFolder.Child("Test").Child("Target")
  targetCount = targetFolder.Count

// If there are files in the source and target folders, then
// grab their names and absolute paths and add rows to your
// two main ListBoxes as well as the temporary dictionaries
// sourceDict and targetDict.
// Dictionary Values = file name, Dictionary Keys = AbsolutePath.
// If you find the results aren't working properly, you might
// need to reverse this to:
// Dictionary Values = AbsolutePath, Dictionary Keys = file name?
// Remember, AbsolutePaths are generally discouraged.  Be very
// careful when you use them.  Macs allow volumes to be mounted
// that might have the same name.
  If sourceCount > 0 then
    For i = 1 to sourceCount
      sourceName = sourceFolder.Item(i).Name
      sourcePath = sourceFolder.Item(i).AbsolutePath
      SourceList.AddRow sourceName
      sourceDict.Value(sourceName) = sourcePath
    Next
  End If
  
  If targetCount > 0 then
    For i = 1 to targetCount
      targetName = targetFolder.Item(i).Name
      targetPath = targetFolder.Item(i).AbsolutePath
      TargetList.AddRow targetName
      targetDict.Value(targetName) = targetPath
    Next
  End If

// Copy the temporary Dictionary information to the
// Dictionary properties.  This allows you to use the
// Dictionary information in other Methods.  You should
// probably clear the dictionaries at this point so that  
  SourceDictionary = sourceDict
  TargetDictionary = targetDict

_________________________________________________________

You should also note that this is a simple example.  I think what you are
trying to do is a lot more involved.

> If the first snippet is under the Action of a Pushbutton, where would the
main code go?

Anywhere you like.  For this test, it was in the Open event of the window.
You would probably want to call it from a PushButton, or call a separate
method from a PushButton.


_______________________________________________
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>

_______________________________________________
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