//ハイパー日記システム支援マクロ(hnfファイル作成秀丸マクロ) //hnf.mac ver.1.31 //(C)2002-2003 hiro http://village.infoweb.ne.jp/~fwnk1502/ //最新版と詳しい説明はhttp://village.infoweb.ne.jp/~fwnk1502/data/hns_for_pnamazu.html#hidemaru //※以下の項目について設定してください。 // OSの選択。WindowsXP、2000の場合は1。Windows95、98、Meは0を記入してください。 $win = "1"; // hnfファイルの保存先(ローカルの日記フォルダの指定) //C:\Diaryの場合はc:\\diary。\は2つ必要です。 $hnfdir = "c:\\diary"; // 接続するサーバー $server = "foo.bar.ne.jp"; //ユーザー名 $user="hoge"; //パスワード $passwd="pass1234"; //アップロードするサーバーの日記ディレクトリ $ftpdir ="/home/hoge/diary"; //翌日の何時までをその日の日記にするかの設定。午前1時までの場合は //半角数字で1を記入。午前0時を過ぎたら次の日の日記にする場合は0。 #sethour=1; //---------------設定終了------------------------------ #hour=val(hour); $day=day; $month=month; $year=year; if(#hour >= #sethour){ $today=$day; }else{ call yestSub; } $basename = "d" + $year + $month + $today + ".hnf"; $hnfdir2 = $hnfdir + "\\" + $year; #hnffile = existfile($hnfdir2 +"\\"+ $basename); if(! existfile($hnfdir2)){question "日記の管理には専用フォルダが必要です。 \n\n日記フォルダ" + $hnfdir2 + "を作成しますか?"; if(result == 1){ call mdSub; }else{ message "日記作成を終了します。"; endmacro;} goto WriteSub;} mousemenu "1. 日記作成","2. hnsコマンドメニュー","3. ファイル転送","4. 日記検索", "5. 日記フォルダを開く","6. 日付指定で日記作成","7. 年を指定せずに日記作成","8. 終了"; if( result == 0 ) endmacro; else if( result == 1 ){ call WriteSub ; } else if( result == 2 ){ call HnfmenuSub ; } else if( result == 3 ){ call ftpSub ; } else if( result == 4 ){ call grepSub ; }else if( result == 5 ){ call openSub ; }else if( result == 6 ){ call pastSub; }else if( result == 7 ){ call noyearSub; }else{ endmacro; } endmacro; //-------日記作成サブルーチン------------------------- WriteSub: if(existfile($hnfdir2 + "\\" + "nul")){ if(#hnffile == 0){ question "きょうの日記はまだありません。作成しますか?"; if(result == yes){ call templateSub; }else{ call quesSub; } }else{ question "きょうの日記ファイルを開きますか?"; if(result == yes){ openfile $hnfdir2 + "\\" + $basename, euc, lf; }else{ call quesSub; } } }else{message "日記作成を終了します。"; endmacro;} endmacro; //----------hnfコマンドサブルーチン----------------------------------- //よく使うコマンドを同じ書式で書いておくと便利です。 HnfmenuSub: mousemenu "1. NEW","2. LNEW","3. LINK","4. URL","5. PRE","6. CAT","7. FN","8. P","9. CITE", "10. UL","11. OL","12. DL","13. SUB","14. 終了"; if( result == 0 ) endmacro; else if( result == 1 ){ insert "NEW "; } else if( result == 2 ){ insert "LNEW "; call LnewSub; } else if( result == 3 ) { insert "LINK "; call LnewSub; } else if( result == 4 ) { insert "URL "; call LnewSub; } else if( result == 5 ) { insert "PRE\n\n"; insert "/PRE\n"; up; up; } else if(result == 6 ) { insert "CAT "; } else if(result == 7 ) { insert "FN\n\n"; insert "/FN\n"; up; up; } else if(result == 8 ) { insert "P\n\n"; insert "/P\n"; up; up; } else if(result == 9 ) { insert "CITE\n\n"; insert "/CITE\n"; up; up; } else if(result == 10 ){ insert "UL\n\n"; insert "/UL\n"; } else if(result == 11 ){ insert "OL\n\n"; insert "/OL\n"; }else if(result == 12 ){ insert "DL\n\n"; insert "/DL\n"; }else if(result == 13 ){ insert "SUB\n"; }else{endmacro; } endmacro; //-------ftpサブルーチン------------------------------------------- ftpSub: save; $putfile = directory2 + "/" + basename2; $upfile = basename2; $ftpdir2=$ftpdir + directory2; $file = "ftp.scr"; openfile ""; insert "user" + " " + $user + " " + $passwd ; insert "\n"; insert "cd" + " " + $ftpdir2; insert "\n"; insert "put" + " " + $putfile; insert "\n"; insert "bye"; up; replaceup $hnfdir, ""; replaceallfast "\\", "/"; saveas hidemarudir + "\\" + $file; question $upfile + "をアップロードしますか?"; if(result == yes){ runsync "ftp -n -s:ftp.scr" + " "+ $server; if (!result){message "FTPに失敗しました\n設定を確認してください。";} else{message $upfile + "をアップロードしました。"; exit;} }else{endmacro;} endmacro; //-------grepサブルーチン------------------------------------------ grepSub: $word = input("検索キーワードを入力してください。"); if( result == 0 ) { endmacro; }else{ grep $word, "*.hnf", $hnfdir, subdir; } endmacro; //------------日記ファイルを開くサブルーチン--------------------------- openSub: openfile $hnfdir2 + "\\" + "*.hnf" ; endmacro; //-----------日付指定サブルーチン------------------------------ pastSub: call leapSub; $mymonth = input("何月の日記を書きますか。 \n半角数字で入力してください。"); if(result == 0){endmacro;} if(strlen($mymonth) != 2){$mymonth = "0" + $mymonth;} #mymonth = val($mymonth); if(#mymonth <= 0 || #mymonth > 12){ message "月指定に誤りがあります"; endmacro; } $myday = input("何日の日記を書きますか? \n半角数字で入力してください。\n"); if(result == 0){endmacro;} if(strlen($myday) != 2){$myday = "0" + $myday;} #myday = val($myday); if(#mymonth == 4 || #mymonth == 6 || #mymonth == 9 || #mymonth == 11 && #myday > 30){ message "日指定に誤りがあります。"; endmacro; } else if(#mymonth == 2 && #day > #mymonth_days){ message "2月の日指定に誤りがあります。"; endmacro; } else if(#mymonth == 3 || #mymonth == 5 || #mymonth ==7 || #mymonth == 8 || #mymonth == 10 || #mymonth == 12 && #day > 31){ message "日指定に誤りがあります。"; endmacro; } $word2 = $mymonth + $myday; if( result == 0 ) { endmacro; }else{ #word2 = val($word2); if(#word2 < 101 ){ message "日付指定に誤りがあります!"; endmacro; }else if(strlen($word2) != 4){ message "日付指定に誤りがあります!"; endmacro; }else{ $basename2 = "d" + year + $word2 + ".hnf"; #hnffile2 = existfile($hnfdir2 +"\\"+ $basename2); if(#hnffile2 == 1){ question "その日の日記は既にあります。ファイルを開きますか?"; if(result == 1){ openfile $hnfdir2 + "\\" + $basename2, euc, lf; }else{ endmacro;} }else{ $basename=$basename2; call templateSub; } } } endmacro; //-----------前日の日付を得るサブルーチン------------------------------ yestSub: if(val($day)==1){ if(val($month)==5 || val($month)==7 || val($month)==10 || val($month)==12) {$today="30"; $month = str(val($month)-1); if(val($month)<10){$month = "0" + $month;} }else if(val($month)==2 || val($month)==4 || val($month)==6 || val($month)==8 || val($month)==9 || val($month)==11) {$today="31"; $month = str(val($month)-1); if(val($month)<10){$month = "0" + $month;} }else if(val($month)==3){ $month = "02"; call leapSub; $today=str(#month_days); }else{ $today="31"; $month="12"; $year=str(val($year)-1); } }else{#today=val($day)-1; $today = str(#today); if(#today<10){$today ="0" + $today;} } return; //-----------うるう年計算サブルーチン----------------------------------- leapSub: $year = year; #year = val($year); if((#year % 4 ) == 0 && (#year % 100) != 0 || (#year % 400) == 0) {#month_days = 29; }else{ #month_days = 28;} return #month_days; //-----------フォルダ作成サブルーチン----------------------------- mdSub: if($win == "1" ){ runsync2 "cmd.exe /c mkdir" + " "+ $hnfdir2 ; if(! existfile($hnfdir2)){ message "日記フォルダ作成に失敗しました。 \nOSの選択設定に誤りがあります。 \nWindows95,98,Meの場合は \n設定を$win = \"0\"としてください。"; endmacro; }else{goto WriteSub;} }else if($win == "0" ){ runsync2 "command.com /c mkdir" + " "+ $hnfdir2 ; if(! existfile($hnfdir2)){ message "日記フォルダ作成に失敗しました。 \nOSの選択設定に誤りがあります。 \nWindows2000とXPの場合は \n設定を$win = \"1\"としてください。"; endmacro; }else{goto WriteSub;} }else{ message "日記フォルダ作成に失敗しました。 \nOSの選択設定に誤りがあります。 \n$win = は半角数字で0か1を記入してください。"; endmacro;} endmacro; //--------------年月日を指定せずに日記作成------------------------------- noyearSub: if(!existfile($hnfdir + "\\" + "d00000000.hnf")){ openfile ""; //insert "TENKI\n"; //insert "TAIJU\n"; //insert "SUIMIN\n"; insert "OK\n\n"; insert "NEW "; imeswitch; saveas $hnfdir + "\\" + "d00000000.hnf", euc, lf ; message "年月日の指定がない日記ファイル\n d00000000.hnfを" + $hnfdir + "に作成しました。"; endmacro;} else{message "年月日指定のない日記が既にあります。 \nファイルを削除するか、名前を変更した上で、 \nもう一度実行してください。"; run "explorer " + $hnfdir; } endmacro; //------------------LNEWコマンドサブルーチン----------------------- LnewSub: ddeinitiate "iexplore", "WWW_GetWindowInfo"; if(!result){ddeinitiate "sleipnir", "WWW_GetWindowInfo"; if(!result){ddeinitiate "mozilla", "WWW_GetWindowInfo"; if(!result){ddeinitiate "Mozilla Firebird", "WWW_GetWindowInfo"; if(!result){ddeinitiate "Opera", "WWW_GetWindowInfo"; if(!result){message "対応ブラウザが起動していません。"; endmacro;} } } } } $url = dderequest( "0xFFFFFFFF" ); $url2 = $url; ddeterminate; if( leftstr($url, 1) == "\"" ) { $url = midstr($url, 1, 1024); #x = strstr($url, "\""); if( #x >= 0 ) { $url = leftstr($url, #x); } } $url2 = midstr($url2, #x, 1024); $url2 = midstr($url2, 4, 1024); #y = strstr($url2, ","); #y = #y-1; $url2 = leftstr($url2, #y); insert $url; insert " "; insert $url2; insert "\n"; endmacro; //--------------条件分岐サブルーチン----------------------------------- quesSub: question "日記フォルダを開きますか?"; if(result == yes){ call openSub; imeswitch; }else{ question "日付を指定して日記を書きますか?"; if(result == yes){ call pastSub; }else{ message "日記作成を終了します。"; endmacro; } } endmacro; //--------------日記テンプレートサブルーチン---------------------------- templateSub: openfile ""; //insert "TENKI\n"; //insert "TAIJU\n"; //insert "SUIMIN\n"; insert "OK\n\n"; insert "NEW "; imeswitch; saveas $hnfdir2 + "\\" + $basename, euc, lf ; endmacro;