|
|
|
ダウンロード:季語だけ俳句_Mac.zip ダウンロード:季語だけ俳句_Win.zip ダウンロード:haiku.livecode Livecodeのオープンソース・ドキュメントです。 ドキュメントは 無料のLiveCode Community Editionで開くことができます |
作者にドネーションをよろしく index@kenjikojima.com |
on mouseUp
-- 季語データが作成されていない場合ダイアログを出して、ステートメントを終了
if fld 1 is empty then
beep
answer "始めに季語データを作成してください。"
exit to top
end if
-- 月のメニューから指定する月を得る
put the label of btn "月メニュー" into t月
-- 上句(季語1つ)、中句(季語2つ)、下句(季語1つ)をつないでフィールドに表示
put 選季語(t月) & " " & 選季語(t月) & 選季語(t月) & " " & 選季語(t月) into fld "俳句"
end mouseUp
-- 指定した月のフィールドから任意の行を取得
private function 選季語 p月
repeat forever
get any line of fld p月
-- 7文字以上の行を選んだらやり直し(季語ではなく説明文)
if num of chars of it < 7 then exit repeat
end repeat
return it
end 選季語
---------// 3)季語だけ俳句を作る ここまで//---------
-- 直接俳句とは関係ないけれど、イントロです。
on mouseUp
set cursor to watch
lock screen
--URLからデータを取得して SJIS の文字コードをユニコードに変換
get URL "http://www.kyoto.zaq.ne.jp/masuhiro/kigoichiran.html"
set the htmlText of field 1 to it
set the unicodeText of field 1 to uniEncode(field 1,Japanese)
put fld 1 into t季語一覧
if line 1 of t季語一覧 is not "俳句季語一覧 " then
beep
put "" into fld 1
answer "何らかのトラブルでデータが取得できません。"
exit to top
end if
-- ウェブページのデータ作成の不揃いを修正
replace "、" with cr in t季語一覧
replace "・" with cr in t季語一覧
replace " " with empty in t季語一覧
replace " " with empty in t季語一覧
replace " " with empty in t季語一覧
replace "他" with empty in t季語一覧
replace "2月20日" with empty in t季語一覧
replace "(" with cr in t季語一覧
replace ")" with cr in t季語一覧
replace "(" with cr in t季語一覧
replace ")" with cr in t季語一覧
replace "〔" with cr in t季語一覧
-- それぞれの月の行の数(位置)を取得
put lineOffset("一月", t季語一覧) into t行1
put lineOffset("二月", t季語一覧) into t行2
put lineOffset("三月", t季語一覧) into t行3
put lineOffset("四月", t季語一覧) into t行4
put lineOffset("五月", t季語一覧) into t行5
put lineOffset("六月", t季語一覧) into t行6
put lineOffset("七月", t季語一覧) into t行7
put lineOffset("八月", t季語一覧) into t行8
put lineOffset("九月", t季語一覧) into t行9
put lineOffset("十月", t季語一覧) into t行10
put lineOffset("十一月", t季語一覧) into t行11
put lineOffset("十二月", t季語一覧) into t行12
-- 各月のテキストフィールドに入れて季語データとする
put line t行1 + 1 to t行2 - 3 of t季語一覧 into 一月
各月季語 一月, "一月"
put line t行2 + 1 to t行3 - 3 of t季語一覧 into 二月
各月季語 二月, "二月"
put line t行3 + 1 to t行4 - 3 of t季語一覧 into 三月
各月季語 三月, "三月"
put line t行4 + 1 to t行5 - 3 of t季語一覧 into 四月
各月季語 四月, "四月"
put line t行5 + 1 to t行6 - 3 of t季語一覧 into 五月
各月季語 五月, "五月"
put line t行6 + 1 to t行7 - 3 of t季語一覧 into 六月
各月季語 六月, "六月"
put line t行7 + 1 to t行8 - 3 of t季語一覧 into 七月
各月季語 七月, "七月"
put line t行8 + 1 to t行9 - 3 of t季語一覧 into 八月
各月季語 八月, "八月"
put line t行9 + 1 to t行10 - 3 of t季語一覧 into 九月
各月季語 九月, "九月"
put line t行10 + 1 to t行11 - 3 of t季語一覧 into 十月
各月季語 十月, "十月"
put line t行11 + 1 to t行12 - 3 of t季語一覧 into 十一月
各月季語 十一月, "十一月"
put line t行12 + 1 to - 3 of t季語一覧 into 十二月
各月季語 十二月, "十二月"
end mouseUp
-- 取得した月のデータの空白の行を削除するファンクション
private command 各月季語 p月, pフィールド
repeat for each line tLine in p月
if tLine is empty then put "" after t季語 \
else put tLine &cr after t季語
end repeat
delete the last char of t季語 -- 最後のリターン・キャラクターを削除
put t季語 into fld pフィールド
end 各月季語
---------// 1)季語データ作成ここまで //---------