AppleScript名:原稿用紙枚数シミュレーション(簡易版)v1 |
— Created 2018-1-13 by Takaaki Naganoya — 2018 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" –http://piyocast.com/as/archives/5120 set aText to retTestText() of me set sRes to genkoSimulation(20, 20, aText) of me display notification "原稿用紙換算で約" & (sRes as string) & "枚です" –原稿用紙枚数シミュレーション(簡易版) on genkoSimulation(lineMax as integer, genkoLineMax as integer, aText as string) script spdT property aList : {} end script if aText = "" then return 0 set (aList of spdT) to characters of aText set charPointer to 1 set lineCounter to 1 set aLen to length of (aList of spdT) set i to 1 repeat while i < aLen set j to contents of item i of (aList of spdT) if j is in {string id 10, string id 13, string id 10 & string id 13} then set charPointer to 1 set lineCounter to lineCounter + 1 else set charPointer to charPointer + 1 if charPointer ≥ lineMax then set charPointer to 1 set lineCounter to lineCounter + 1 end if end if set i to i + 1 end repeat set totalPage to lineCounter div genkoLineMax set amariPage to lineCounter mod genkoLineMax if amariPage = 0 then — else set totalPage to totalPage + 1 end if return totalPage end genkoSimulation on retTestText() return "12345 あいうえお かきくけこ さしすせそ たちつてと なにぬねの はひふへほ まみむめも やいゆえよ わいうえを あいうえお かきくけこ さしすせそ たちつてと なにぬねの はひふへほ まみむめも やいゆえよ わいうえを 1234567890123456789ぉー" end retTestText |
More from my site
(Visited 63 times, 1 visits today)