' 日記マクロ '【カスタマイズ】==================================================== const NIKKI_DIR$ ="" '日記を書き出すディレクトリ。 '指定なければマクロディレクトリに書き出す。 const NIKKI_FILE$ ="NIKKI.TXT" '日記本体のファイル名 const NIKKI_TMP$ ="temp.nik" '作業ファイル(このままにしておいてください) '==================================================================== dim pn$, tn$ proc main dim item$[10], sel, n item$[n++]="" item$[n++]=cformat$("%s*%s日記マクロ *", chr$(1), chr$(9)) item$[n++]="-" item$[n++]=cformat$("&W%s日記を書く", chr$(9)) item$[n++]=cformat$("&S%s日記を保存", chr$(9)) item$[n++]=cformat$("&R%s日記を見る", chr$(9)) item$[n++]="-" item$[n++]=cformat$("&C%sキャンセル", chr$(9)) sel=popupmenu(item$, 10, 20) if sel=3 then nikki elseif sel=4 then addnik elseif sel=5 then readnik end if end proc proc nikki init dim fn fn=freefile() open tn$ for output as #fn close #fn call @@OpenFile(tn$) @Redraw=0 @UndoBlock=1 dim d$ d$=mid$(date0$, 1, 4)+"/"+mid$(date0$, 6, 2)+"/"+mid$(date0$, 9, 2) @Insert cformat$("%s (%s)", d$, week$(-weekday)) @CharReturn2 @CharReturn2 @StyleNo=10 @Line=2 @UndoBlock=0 @Redraw=1 ErrorEnd "日記ファイルを開きました。" end proc proc addnik dim r, s$ if @hwnd=0 then ErrorEnd "日記ファイルを編集してください。" init s$="["+@Filename$+"]は日記ファイルではありません。" if lcase$(@Pathname$)<>tn$ then ErrorEnd s$ dim x,y x=@XDisplay: y=@Line @Redraw=0 @MoveFileBottom @Line=y: @XDisplay=x @Redraw=1 if @@ActiveFile(pn$) then s$="追加先ファイルが編集されています。"+chr$(13)+chr$(13)+chr$(9) s$=s$+"追加先ファイルの編集を終了する時は『はい』を"+chr$(13)+chr$(9) s$=s$+"日記追加マクロの実行を終了する時は『いいえ』を"+chr$(13) s$=s$+chr$(13)+"をそれぞれ押してください。" r=msgbox(s$, MB_YESNO, "日記マクロ") if r=IDNO then ErrorEnd "" else if @Modify then s$="ファイルが変更されています。"+chr$(13) s$=s$+"ファイルを保存しますか?" r=msgbox(s$, MB_YESNOCANCEL, "日記マクロ") if r=IDCANCEL then ErrorEnd "" elseif r=IDOK then @FileSave else @Modify=0 end if end if @FileClose end if end if dim fn fn=freefile() open pn$ for append as #fn dim i i=1 do while i<@LastLine+1 print #fn, @Text$(i++) loop print #fn, "--------以上("+date0$+" "+time0$+")" print #fn, "" close #fn s$="日記ファイルを追加しました。"+chr$(13)+"日記編集を終了します。" r=msgbox(s$, MB_OKCANCEL, "日記マクロ") if r=IDOK then @FileSave @FileClose ErrorEnd "日記編集を終了しました。" end if end proc proc readnik dim hwnd as HWND init if dir$(pn$)="" then ErrorEnd "日記ファイル["+pn$+"]がありません。" hwnd=@@OpenFile(pn$) dim n, tmp$[10] do while n<10 tmp$[n]=@Caption$(n+1) n++ @Caption$(n)="" loop @Caption$(1)="--------以上(" @ListCaption n=0 do while n<10 @Caption$(n+1)=tmp$[n] n++ loop @Redraw=0 @FindStringTop "--------以上(" @MoveDownChar @MoveDownChar @MoveDownChar @Redraw=1 end proc sub ErrorEnd(s$) print s$ end end sub sub init if NIKKI_DIR$="" then pn$=lcase$(@@MacroDirectory$) tn$=pn$+"\"+lcase$(NIKKI_TMP$) pn$=pn$+"\"+lcase$(NIKKI_FILE$) end sub