2D List内で項目を検索して、ヒットした項目をすべて{x,y}のアイテム番号リストで返すAppleScriptです。
# 年がら年中、この手のScriptを書き捨てているような気もしますが、、、
Excelのワークシート上の情報をすべて読み取って、2D Listの中をデータ検索するような処理で使うための部品です。
AppleScript名:2D List内で検索してヒットした情報をすべて返す.scptd |
— – Created by: Takaaki Naganoya – Created on: 2019/01/24 — – Copyright © 2019 Piyomaru Software, All Rights Reserved — use AppleScript version "2.4" — Yosemite (10.10) or later use framework "Foundation" use scripting additions use Bplus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html set anItem to "a" set aList to {{"b", "a", "c", "a"}, {"a", "a", "c", "a"}, {"b", "v", "c", "a"}, {"b", "a", "c", "a"}} set bRes to findDataFrom2DList(anItem, aList) of me –> {{2, 1}, {4, 1}, {1, 2}, {2, 2}, {4, 2}, {4, 3}, {2, 4}, {4, 4}} on findDataFrom2DList(anItem, aList) script spd property aList : {} property resList : {} end script set (aList of spd) to aList set (resList of spd) to {} set yCount to 1 repeat with i in (aList of spd) set aResList to (Bplus’s indexesOfItem:anItem inList:i inverting:false) as list set tmpList to {} if aResList is not equal to {} then repeat with ii in aResList set jj to contents of ii set the end of tmpList to {jj, yCount} end repeat set (resList of spd) to (resList of spd) & tmpList end if set yCount to yCount + 1 end repeat return (resList of spd) –return {{x, y}…..} item list (1-based) end findDataFrom2DList |
More from my site
(Visited 86 times, 1 visits today)
Pages書類の1ページ目の表の背景色を置換 v3(約20倍速) – AppleScriptの穴 says:
[…] v2では、高速化のために全セルの背景色を抽出したあとに、2次元配列データ上で当該セルの座標を計算し、塗り替え対象セルのみ処理することで約35%のスピードアップを行いました。 […]