AppleScript名:ASOCでレコードのリストから抽出 |
— Created 2017-08-05 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set dList to {{deviceName:"Piyomaru AirPods", deviceAddress:"7c-04-d0-8b-bc-fb"}, {deviceName:"Takaaki Naganoya のマウス", deviceAddress:"ac-bc-32-dd-99-3e"}, {deviceName:"Takaaki Naganoya のキーボード #1", deviceAddress:"04-69-f8-be-2a-c7"}} set dRes to filterRecListByLabel(dList, "deviceName contains ’AirPods’") of me if dRes = {} then return false –Case: No match set dAddr to dRes’s first item’s deviceAddress return dAddr –リストに入れたレコードを、指定の属性ラベルの値で抽出 on filterRecListByLabel(aRecList as list, aPredicate as string) –ListからNSArrayへの型変換 set aArray to current application’s NSArray’s arrayWithArray:aRecList –抽出 set aPredicate to current application’s NSPredicate’s predicateWithFormat:aPredicate set filteredArray to aArray’s filteredArrayUsingPredicate:aPredicate –NSArrayからListに型変換して返す set bList to filteredArray as list return bList end filterRecListByLabel |
More from my site
(Visited 51 times, 1 visits today)