BUG REPORT
Running Keyboard Maestro 9.1 on macOS 10.14.6 (Mojave)
@peternlewis, the following script runs fine from both FastScripts and Script Debugger 7.
But when run from a KM Execute AppleScript, with either a script file or script text, I get this error:
/var/folders/hb/6xgg0y8j4g530m81rd1f9mpc0000gp/T/Keyboard-Maestro-Script-B3C7577B-D5D6-4B32-BDED-15DB9BDBEC60:2014:2039: execution error: The bundle “BridgePlus” couldn’t be loaded. (-4960)
/Users/Shared/Dropbox/SW/DEV/LINKED_FOLDERS/Scripts/@KM -- Select KM Macro Created Last.scpt: execution error: The bundle “BridgePlus” couldn’t be loaded. (-4960)
property ptyScriptName : "Select Macro Created Last"
property ptyScriptVer : "1.0"
property ptyScriptDate : "2020-11-23"
property ptyScriptAuthor : "JMichaelTX"
use AppleScript version "2.5"
use scripting additions
use framework "Foundation" -- Required for all ASObjC commands
use BPLib : script "BridgePlus" -- required for sortMultiLists() handler
(*
REQUIRES:
use framework "Foundation"
use BPLib : script "BridgePlus"
REF: BridgePlus 1.3.3 Script Library, Shane Stanley
https://latenightsw.com/support/freeware/
*)
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tell application "Keyboard Maestro"
activate
set {macroUUIDList, macroCreationDateList} to {id, creation date} of every macro
set {macroCreationDateList, macroUUIDList} to my sortMultiLists({macroCreationDateList, macroUUIDList}, {"DESC", "ASC"})
set macroUUID to (item 1 of macroUUIDList)
set oMacro to macro id macroUUID
select oMacro
set macroName to name of oMacro
set msgStr to "Macro: " & macroName
display notification msgStr with title ptyScriptName sound name "Tink"
return macroName
end tell
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
on sortMultiLists(pListOfLists, pSortDirList) -- @Lists @Sort @BridgePlus @ASObjC
--–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
(* VER: 1.0 2020-11-23
PURPOSE:
PARAMETERS:
• pListOfLists | list | List that contains two or more lists to be sorted
• Lists will be sorted by each sub-list in the order entered.
• pSortDirList | list | List of text items indicating the sort direction for each list
• Must be "ASC" (for ascending) or
• "DESC" (for descending)
RETURNS: List of Lists in Sorted Order
AUTHOR: JMichaelTX
REQUIRES:
use framework "Foundation"
use BPLib : script "BridgePlus"
REF: BridgePlus 1.3.3 Script Library, Shane Stanley
https://latenightsw.com/support/freeware/
--–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
*)
local rowsList, listCount, sortByList, iL, oSort
--- Setup the Sort ---
set rowsList to BPLib's colsToRowsIn:pListOfLists
set listCount to count of pListOfLists
set sortByList to {}
--- Sort Order by List as Passed in pListOfLists ---
repeat with iL from 1 to listCount
set end of sortByList to iL
end repeat
--- Convert Text Sort Direction to Boolean ---
-- (true means ascending)
repeat with oSort in pSortDirList
set contents of oSort to ((oSort as text) starts with "ASC")
end repeat
--- Do the Sort
set rowsList to BPLib's sublistsIn:rowsList sortedByIndexes:sortByList ascending:pSortDirList sortTypes:{}
--- Get Sort Results ---
set pListOfLists to BPLib's colsToRowsIn:rowsList
return pListOfLists
end sortMultiLists
--~~~~~~~~~~~~~~~~~~~~ END of Handler ~~~~~~~~~~~~~~~~~~~~~~~~~~~~