Hi all
The below code has worked flawlessly for a long time, until I upgraded to OS X 10.13.1.
When an item in a drop box is selected like this text “CSR” the search goes and finds all files that have CSRSTOCK in it ie: “12345-M110-CSRSTOCK.ps”
After the upgrade nothing shows in the “aPopupMenu”, and I see no errors either, which I find strange.
I am still slowly trying to learn about apple script objc, and would appreciate any one offering possible reasons or fixes, as I really dont no where to look to try and sort out what broken.
I hope iv’e explained enough not to make this to confusing, and thanks for any help.
Property
property aPopupMenu : missing value
This builds a list in a drop box
set ClientStockItems to {"Client Stock", "CSR"}
try
ClientStockStyle's removeAllItems()
end try
ClientStockStyle's addItemsWithTitles:ClientStockItems
This adds all items from an external drive to a list that have “CSRSTOCK” in the name i.e. “12345-M110-CSRSTOCK.ps”
on MakeCLientStockChoice_(sender)
set productType to ClientStockStyle's titleOfSelectedItem()
set _OpqType to productType as string
if _OpqType is "CSR" then
makeMenu_("CSRSTOCK", -1)
end if
end MakeCLientStockChoice_
This does all the searching and adds all files that have CSRSTOCK" into a drop box for selection, once the wanted file is selected the file is then sent to an output device. (this part was written by Stefank and has worked flawlessly)
on makeMenu_(searchString)
NSNotificationCenter's defaultCenter's addObserver_selector_name_object_(me, "queryDidFinish:", "NSMetadataQueryDidFinishGatheringNotification", missing value)
set pathExtension to "ps"
set searchPath to "/Volumes/RIP FILES/"
set searchKey to quote & "*" & searchString & "*." & pathExtension & quote
set predicate to NSPredicate's predicateWithFormat_("kMDItemFSName like[c] " & searchKey)
set query to NSMetadataQuery's alloc()'s init()
query's setSearchScopes_({searchPath})
query's setPredicate_(predicate)
query's startQuery()
end makeMenu_
on queryDidFinish_(theNote)
query's stopQuery()
aPopupMenu's removeAllItems()
set foundItems to theNote's |object|()'s results()
-------------------------- THIS MAKES TEXT IN DROP BOX EITHER ASCENDING OR DESCENDING -------------------------------------
set sorter to current application's NSSortDescriptor's sortDescriptorWithKey_ascending_("kMDItemFSName",true) --ASCENDING
--set sorter to current application's NSSortDescriptor's sortDescriptorWithKey_ascending_("kMDItemFSName",false) --DESCENDING
set foundItems to foundItems's sortedArrayUsingDescriptors_({sorter})
---------------------------------------------------------------------------------------------------------------------------
repeat with anItem in foundItems
aPopupMenu's addItemWithTitle_(anItem's valueForAttribute_(current application's NSMetadataItemFSNameKey)'s stringByDeletingPathExtension())
end
NSNotificationCenter's defaultCenter's removeObserver_(me)
end queryDidFinish_
cheers
Budgie