-
-
Save kureikei/e0e158cf3ec40fdf3722 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on displayHaiku(haiku) | |
set haiku_lines to paragraphs of haiku -- 各行 (linesは予約後(の複数形)なので使えない!) | |
set max_length to 0 -- 一番長い行の文字数 | |
repeat with ln in haiku_lines -- line、lengthは予約後なので使えない! | |
set len to length of ln | |
if max_length < len then set max_length to len | |
end repeat | |
set line_count to count haiku_lines -- 行数 | |
set tategaki to "" | |
repeat with i from 1 to max_length | |
repeat with j from 1 to line_count | |
set ln to item (line_count + 1 - j) of haiku_lines -- 下の行から上の行へ | |
if length of ln ≥ i then -- 文字がなかった場合にエラーが出るからifで分けなきゃいけない | |
set chr to character i of ln -- 一文字ずつ取り出す | |
else | |
set chr to " " -- 文字数が足りない場合は空白で埋める | |
end if | |
set tategaki to tategaki & chr -- 文字を追加 | |
end repeat | |
set tategaki to tategaki & "\n" | |
end repeat | |
-- 表示 | |
-- say haiku -- せっかくだから喋らせたかったけど「いにしえいけや」って喋るからやめた | |
display alert tategaki buttons "よい" | |
end displayHaiku | |
displayHaiku("古池や\n蛙飛びこむ\n水の音") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment