AppleScript名:ASOCでテキストとリストの変換 |
— Created 2015-10-14 by Takaaki Naganoya — 2015 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set aList to {"あああああ", "いいいいいいいい", "ううううううううううう", "えええええええええええ", "おおおおおおおおおお"} set aRes to my retStrFromArrayWithDelimiter(aList, return) (* "あああああ いいいいいいいい ううううううううううう えええええええええええ おおおおおおおおおお" *) set bList to my parseByDelim(aRes, return) –> {"あああああ", "いいいいいいいい", "ううううううううううう", "えええええええええええ", "おおおおおおおおおお"} –リストを指定デリミタをはさんでテキスト化 on retStrFromArrayWithDelimiter(aList, aDelim) set anArray to current application’s NSArray’s arrayWithArray:aList set aRes to anArray’s componentsJoinedByString:aDelim return aRes as text end retStrFromArrayWithDelimiter on retArrowText(aList, aDelim) –自分のASでよく使うハンドラ名称なので、同じものを用意 return my retStrFromArrayWithDelimiter(aList, aDelim) end retArrowText –テキストを指定デリミタでリスト化 on parseByDelim(aData, aDelim) set aText to current application’s NSString’s stringWithString:aData set aList to aText’s componentsSeparatedByString:aDelim return aList as list end parseByDelim |
More from my site
(Visited 19 times, 1 visits today)