Platforms to show: All Mac Windows Linux Cross-Platform

/MacOSX/Spotlight File Info
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /MacOSX/Spotlight File Info
This example is the version from Wed, 12th Jan 2010.
Notes: Last modified: Wed, 12th Jan 2010
Class App
Inherits Application
// Constants
Const kFileQuitShortcut = Ctrl+Q
Const kFileQuit = &Beenden
Const kEditClear =

// Event implementations
Sub OpenDocument(item As FolderItem)
window1.run item

End Sub
Sub Open()
// you can load

'dim f as FolderItem = GetFolderItem("/Developer/Applications/Xcode.app/Contents/Library/Spotlight/SourceCode.mdimporter", FolderItem.PathTypeShell)
'
'if f.SpotLightLoadMDImporterMBS then
'MsgBox "Loaded SourceCode importer."
'end if

End Sub
End Class

Class Window1
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance

// Event implementations
Sub Open()
run GetFolderItem("Spotlight File Info.rbp")

me.AcceptFileDrop FileTypes1.Any

End Sub
Sub DropObject(obj As DragItem)
do
if obj.FolderItemAvailable then
run obj.FolderItem
end if
loop until not obj.NextItem
End Sub

// Methods
Sub run(f as FolderItem)
dim s as string

if f<>nil then
s = f.SpotLightTextContentMBS
if len(s) = 0 then
s = f.SpotLightTextContentMBS("public.plain-text")
end if
end if

EditField1.text = s

List.DeleteAllRows

dim d as Dictionary = f.SpotLightFileInfoMBS
if d = nil then
d = f.SpotLightFileInfoMBS("public.plain-text")
end if

if d<>nil then
for each key as Variant in d.Keys
dim value as Variant = d.Value(key)
dim type as integer = VarType(value)

List.AddRow key.StringValue

Select case type
case 0 // nil
List.Cell(List.LastIndex,1)="nil"
case 4105 // array of Variants
dim v(-1) as Variant = value
dim texts(-1) as string

for each vv as Variant in v
texts.Append vv.StringValue
next

List.Cell(List.LastIndex,1)=Join(texts,", ")

else
// all other data types like string or numbers
List.Cell(List.LastIndex,1)=value.StringValue
end Select
next
end if

End Sub
End Class





Links
MBS Realbasic Plugins - Jugendzentrum Nickenich