07-30-2013 03:22 AM - edited 07-30-2013 03:32 AM
As stated in the help entry "Evaluating Search Conditions (DataFinder)"
the following DataFinder advanced search will never yield results:
C1 Channel Name = MyChannel1
C2 Channel Name = MyChannel2
C1 AND C2
But how would I actually search for files that contain both MyChannel1 and MyChannel2?
(which clearly is the intention of people trying above snippet)
07-30-2013 08:11 AM
Well, in the end you have to apply a script to calculate the intersection of the two (or multiple) searches. Run the script below (or use attached file) after each search (for files) to create the wanted intersection:
option explicit
Dim filePathColumn : Set filePathColumn = Navigator.Display.CurrDataFinder.ResultsList.Columns.Add(eSearchFile, "fullpath")
Dim firstSearch
If Not Data.Root.ChannelGroups.Exists("SearchResults") Then
Call Data.Root.ChannelGroups.Add("SearchResults").Activate()
firstSearch = true
Else
Call Data.Root.ChannelGroups("SearchResults").Activate()
firstSearch = false
End If
Dim loadedChannel : Set loadedChannel = Navigator.LoadProperty ("fullpath", Navigator.Display.CurrDataProvider.ResultsList.Elements)(1)
Call ChnMultipleSort(loadedChannel,"",1,1)
If firstSearch Then
loadedChannel.name = "intersection"
Else
Dim intersecChannel : Set intersecChannel = Data.Root.ChannelGroups("SearchResults").Channels("intersection")
Dim iChnLength : iChnLength = intersecChannel.Size
Dim i : For i = iChnLength To 1 Step - 1
If NOT FindInChannel(loadedChannel, 1, loadedChannel.Size, intersecChannel.Values(i)) Then
Call DataBlDel(intersecChannel, i, 1)
End If
Next
Data.Root.ChannelGroups("SearchResults").Channels.Remove(loadedChannel.name)
End If
Function FindInChannel(channel, first, last, wanted)
FindInChannel = false
Dim comp
If first > last Then Exit Function
If first = last Then
comp = StrComp(channel.Values(first), wanted)
If comp = 0 Then FindInChannel = true
Exit Function
End If
Dim middle : middle = (last + first) \ 2
comp = StrComp(channel.Values(middle), wanted)
If comp = 0 Then
FindInChannel = true
Exit Function
End If
If comp = -1 Then
If middle = first Then middle = last
FindInChannel = FindInChannel(channel, middle, last, wanted)
Else
FindInChannel = FindInChannel(channel, first, middle, wanted)
End If
End Function