Platforms to show: All Mac Windows Linux Cross-Platform

/Mac/Catalog Search/Findfile with Thread demo
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /Mac/Catalog Search/Findfile with Thread demo
This example is the version from Mon, 2nd Apr 2006.
Notes: Last modified: Mon, 2nd Apr 2006
Class mainwindow
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
Sub Action() Handles Event
dim w as workthread

w=new workthread
w.run
End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub Open() Handles Event
me.columnalignment(1)=3 // size on right
End Sub
End ControlInstance
ControlInstance
End ControlInstance

// Event implementations
Sub Open()

End Sub
End Class

Class Workthread
Inherits Thread
// Event implementations
Sub Run()
dim c as CatSearchMBS
dim nn,n,i as integer
dim f as folderItem
dim error as boolean // We ignore some errors in this example!
dim k as integer
dim list as listbox
dim v as folderItem
dim catalogchanged as Boolean

catalogchanged=false
mainwindow.runButton.enabled=false
c=new CatSearchMBS

list=mainwindow.list
list.DeleteAllRows

n=volumecount-1

for i=0 to n
v=volume(i)
if c.search(v,true) then
c.name=mainwindow.itext.text
c.partialName=true

nn=c.searchNext
while nn>=0
if nn=2 then
catalogchanged=true
end if
k=k+1
if k=1000 then // something wrong?
msgBox "Takes a long time!? Better we stop."
return
end if
f=c.result
if f<>Nil and nn=0 then // Something found
list.addrow f.name
list.Cell(list.lastIndex,1)=format((f.length+f.resourceForkLength)/1024,"0")+" KB"
list.Cell(list.lastIndex,2)=readable(f.mactype)
list.Cell(list.lastIndex,3)=readable(f.maccreator)
list.Cell(list.lastIndex,4)=v.name
end if

nn=c.searchNext
wend
end if
next
mainwindow.runButton.enabled=true

mainwindow.info.text=str(list.ListCount)+" items found."
if catalogchanged then
MsgBox "The catalog of one of the volumes changed while searching. You may have duplicate items or missing ones."
end if
End Sub

// Methods
Function readable(s as string) As string
// files don't need to have a creator or filetype

if s=chr(0)+chr(0)+chr(0)+chr(0) then
return "?"
else
return s
end if
End Function
End Class

Class App
Inherits Application
End Class


See also:




Links
MBS REAL studio PDF Plugins - Jugendzentrum Nickenich