You need to pass a CFArrayRef to the directories parameter. See the Core Foundation chapter of my declares book at <http:// www.declareSub.com/> for some explanation.

Charles Yeomans

On Jan 25, 2007, at 3:33 PM, Aliacta wrote:

I'm trying to build a declare, but it's not a function, it's a method, i.e. there's not supposed to be any return value and I can't find the RB syntax for it. Also it says I can't pass arrays...

What I have so far is below and gives me a hard crash:

Sub TextChange()
  Dim i As Integer
Declare function MDQuerySetSearchScope Lib "Carbon" (QueryRef as integer, Directories as CFStringRef, Optionbits as integer) as integer

  If not Query.Completed then Query.Stop
  Query.Query ="kMDItemDisplayName = ""*"+me.Text+"*""wc"
  i = MDQuerySetSearchScope(Query.Handle,"",0)
  Query.Run


  'void MDQuerySetSearchScope (
  'MDQueryRef query,
  'CFArrayRef scopeDirectories,
  'OptionBits scopeOptions
  ');
End Sub


'Directories' should be an array. Does anybody have an example on how to build a CFStringRef that represents a directory?

Any pointers would be appreciated.

Thanks,

Marc


Hi Jon,

Can you give me some sample code to get me started? I've never done the 'declare thing' before.

Thanks,

Marc

I would like to limit the search scope of Spotlight to a particular folder (and its sub-folders).

The current RB implementation doesn't allow this. Can anybody provide an example on how declares could be used?

You should be able to set up the SpotlightQuery, then declare against MDQuerySetSearchScope passing in the SpotlightQuery.Handle. Because of how the MDQuery API is, any change to the query string will cause REALbasic to recreate the MDQueryRef underneath the hood, which will require you to re-set the scope afterwards.
_______________________________________________
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