Script doesnt work as expected after upgrade to high sierra

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

One thing that stands out: you passing two arguments to makeMenu_, but it only takes one. Of course, that should never have worked, so perhaps there’s something else going on.

thanks for your input Shane

I moved the xcode set up to a machine with 10.3.1 on it and recompiled it, and some wierd stuff happened

all the text that I had told to be blue in the coded isn’t anymore, its gone back to black, and not sorted in descending format, its not sorted at all.

plus when I click on a button to load text into a drop box “aPopupMenu” I get this error

2017-11-20 11:08:22.241727+1300 FREEZE3[7127:432228] *** -[AppDelegate MostUsed:]: method dictionaryWithObjectsAndKeys: expected 1 arguments, got 5. (error -10000)

The dictionaryWithObjectsAndKeys: method doesn’t work in 10.13. Instead, use dictionaryWithObjects:forKeys:.

thanks for that Shane, changed it, which eliminated the error.

So to get more information, I have now moved the project onto the mac that uses it, and have done a clean and build, now it’s throwing this error upon first launch, not sure what it means

2017-11-20 14:06:46.937122+1300 FREEZE3[60614:1463732] MessageTracer: load_domain_whitelist_search_tree:73: Search tree file’s format version number (0) is not supported
2017-11-20 14:06:46.937492+1300 FREEZE3[60614:1463732] MessageTracer: Falling back to default whitelist

You can probably ignore it.

I think after a lot of shagging around the problem seems to be the main drive is formatted to HFS and the external drive is formatted to APFS, once I reformatted the external back to HFS the problem went away.

Also having the main drive and external drive of APFS stopped the script from working as originally posted.

I thought about downgrading the main and exteranl to HFS, which would stop the issue, but all this would do is put a band aid on sorting this issue as time moves on.

Any suggestions for a work around ?, as id like the code to work using APFS on internal and external drives.

cheers

Or it might provide time for Apple to deal with the APFS issues…