// _______________________ // | | // | テキストデータをHtml形式に変換する | // | Ver2(文字化け対策版) | // | | // | 用途:単なる文書やソースコードをHPにする | // |_______________________| // // コンパイル Html形式に変換 IDM_Comp { if(CompEditText("file_name",0,"noname") == 1){ MessBox("ファイル名がありません","エラー",0,1) ; return ; } OpenFileWrite("html_name") ; WriteFileFromEdit("ID_main") ; CloseFile ; AllSelectEdit("ID_html") ; ClearEdit("ID_html") ; // 全削除 OpenFileRead("html_name") ; ReadFileToEdit("ID_html") ; CloseFile ; call("CheckCharA") ; call("CheckCharB") ; call("CheckCharC") ; SetEditCursol("ID_html",0,0) ; SetEditText("ID_html","<HTML>") ; SetEditCodeRet("ID_html") ; // <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"> SetEditText("ID_html","<HEAD>") ; SetEditCodeRet("ID_html") ; SetEditText("ID_html","<meta http-equiv=") ; SetEditCode("ID_html",34) ; SetEditText("ID_html","Content-type") ; SetEditCode("ID_html",34) ; SetEditText("ID_html"," content=") ; SetEditCode("ID_html",34) ; SetEditText("ID_html","text/html; charset=Shift_JIS") ; SetEditCode("ID_html",34) ; SetEditText("ID_html",">") ; SetEditCodeRet("ID_html") ; SetEditText("ID_html","<TITLE>") ; SetEditText("ID_html","html_name") ; SetEditText("ID_html","</TITLE>") ; SetEditCodeRet("ID_html") ; SetEditText("ID_html","</HEAD>") ; SetEditCodeRet("ID_html") ; // <BODY BGCOLOR="#ffffff" TEXT="#000000"> SetEditText("ID_html","<BODY BGCOLOR=") ; SetEditCode("ID_html",34) ; SetEditText("ID_html","#ffffff") ; SetEditCode("ID_html",34) ; SetEditText("ID_html"," TEXT=") ; SetEditCode("ID_html",34) ; SetEditText("ID_html","#000000") ; SetEditCode("ID_html",34) ; SetEditText("ID_html",">") ; SetEditCodeRet("ID_html") ; // <FONT FACE="MS ゴシック" SIZE=3 COLOR="#000000"> SetEditText("ID_html","<FONT FACE=") ; SetEditCode("ID_html",34) ; SetEditText("ID_html","MS ゴシック") ; SetEditCode("ID_html",34) ; SetEditText("ID_html"," SIZE=3 COLOR=") ; SetEditCode("ID_html",34) ; SetEditText("ID_html","#000000") ; SetEditCode("ID_html",34) ; SetEditText("ID_html",">") ; SetEditCodeRet("ID_html") ; SetEditText("ID_html","<PRE>") ; SetEditCodeRet("ID_html") ; SetEditCursol("ID_html",-1,0) ; SetEditCodeRet("ID_html") ; SetEditText("ID_html","</PRE>") ; SetEditCodeRet("ID_html") ; SetEditText("ID_html","</FONT>") ; SetEditCodeRet("ID_html") ; SetEditText("ID_html","</BODY>") ; SetEditCodeRet("ID_html") ; SetEditText("ID_html","</HTML>") ; SetEditCodeRet("ID_html") ; OpenFileWrite("html_name") ; WriteFileFromEdit("ID_html") ; CloseFile ; MessBox("html ファイル作成しました","完了",0,2) ; } // 特殊記号を書きかえる CheckCharA { len = GetEditLength("ID_html") ; p = 0 ; loop(len){ p = SearchEditText("ID_html",p,"&") ; if(p == -1){ return ; } p = p + 1 ; SetEditCursol("ID_html",p,p) ; SetEditText("ID_html","amp;") ; } } // 特殊記号を書きかえる CheckCharB { len = GetEditLength("ID_html") ; p = 0 ; loop(len){ p = SearchEditText("ID_html",p,"<") ; if(p == -1){ return ; } SetEditCursol("ID_html",p,p+1) ; SetEditText("ID_html","<") ; } } // 特殊記号を書きかえる CheckCharC { len = GetEditLength("ID_html") ; p = 0 ; loop(len){ p = SearchEditText("ID_html",p,">") ; if(p == -1){ return ; } SetEditCursol("ID_html",p,p+1) ; SetEditText("ID_html",">") ; } } // ウインドウのサイズに合わせる SIZE { SetControlSize("ID_main",0,28,WIN_X,WIN_Y-28) ; SetControlFocus("ID_main") ; } // 終了の処理 CLOSE { if(GetEditChange("ID_main") == 1){ AllSelectEdit("ID_text") ; ClearEdit("ID_text") ; // 全削除 SetEditText("ID_text","文書は更新されています") ; SetEditCodeRet("ID_text") ; // 改行 SetEditText("ID_text","終了する前に保存しますか") ; n = MessBox("ID_text","終了",4,3) ;// [はい][いいえ][キャンセル] ? // はい if(n == 1){ call("IDM_SaveAs") ; return ; } // いいえ if(n == 0){ end ; } // キャンセル if(n == -1){ return ; } } end ; } INIT { SetControlFont("ID_main","MS ゴシック",8,16,0) ; SetCaption("file_name") ; } PAINT { Line(0,0,WIN_X,0,14) ; Line(0,1,WIN_X,1, 7) ; } CREATE { SetWinStyle(0) ; SetWinSize(600,400) ; SetWinColor(15) ; Menu("ファイル(&F)") ; PopupMenuEX("開く(&O)","IDM_OpenFile") ; PopupMenuEX("上書き保存(&S)","IDM_Save") ; PopupMenuEX("名前を付けて保存(&A)","IDM_SaveAs") ; PopupMenuEX("---","") ; PopupMenuEX("html に変換(&R)","IDM_Comp") ; PopupMenuEX("---","") ; PopupMenuEX("アプリケーションの終了(&X)","CLOSE") ; Menu("編集(&E)") ; PopupMenuEX("元に戻す(&U) Ctrl+Z","IDM_Undo") ; PopupMenuEX("---","") ; PopupMenuEX("切り取り(&T) Ctrl+X","IDM_Cut") ; PopupMenuEX("コピー(&C) Ctrl+C","IDM_Copy") ; PopupMenuEX("貼り付け(&P) Ctrl+V","IDM_Paste") ; CreateControl(100,"","ID_main",0,0,0,0) ; // 原文データ CreateControl(100,"","ID_html",0,0,0,0) ; // Htmlデータ CreateControl(101,"noname", "file_name",0,0,0,0) ; // ファイル名 CreateControl(101,"noname.html","html_name",0,0,0,0) ; // Html名 CreateControl(101,"","ID_text",0,0,0,0) ; // メッセージ用バッファ // ボタン類 CreateControl(0,"上書き保存","IDM_Save", 2,5,80,20) ; CreateControl(0,"html に変換","IDM_Comp", 90,5,80,20) ; CreateControl(101,"","ID_search_buf",190,5,150,20) ; CreateControl(0,"↓検索","ID_search",350,5,60,20) ; } // ファイル名保存 Make_file_name { AllSelectEdit("file_name") ; ClearEdit("file_name") ; // 全削除 SetEditText("file_name","FILE_NAME") ; } // htmlファイル名作成 Make_html_name { AllSelectEdit("html_name") ; ClearEdit("html_name") ; // 全削除 SetEditText("html_name","file_name") ; n = SearchEditText("html_name",0,".") ; SetEditCursol("html_name",n,n+8) ; SetEditText("html_name",".html") ; } // 「ファイル」メニュー // 開く IDM_OpenFile { if(OpenFileReadDlg("ファイルを開く") <= 0){ SetControlFocus("ID_main") ; return ; } ReadFileToEdit("ID_main") ; CloseFile ; SetEditNoChange("ID_main") ; SetControlFocus("ID_main") ; call("Make_file_name") ; call("Make_html_name") ; SetCaption("file_name") ; SetControlFocus("ID_main") ; } //上書き保存 IDM_Save { if(CompEditText("file_name",0,"noname") == 1){ MessBox("名前を付けて保存してください","エラー",0,1) ; SetControlFocus("ID_main") ; return ; } OpenFileWrite("file_name") ; WriteFileFromEdit("ID_main") ; CloseFile ; SetEditNoChange("ID_main") ; SetControlFocus("ID_main") ; } // 名前を付けて保存 IDM_SaveAs { if(GetEditLength("ID_main") == 0){ SetControlFocus("ID_main") ;return ; } if(OpenFileWriteDlg("名前を付けて保存") <= 0){ return ; } WriteFileFromEdit("ID_main") ; CloseFile ; SetEditNoChange("ID_main") ; call("Make_file_name") ; call("Make_html_name") ; SetCaption("file_name") ; SetControlFocus("ID_main") ; } // 「編集」メニュー IDM_Undo { UndoEdit("ID_main") ; } IDM_Cut { CutEdit("ID_main") ; } IDM_Copy { ClipEdit("ID_main") ; } IDM_Paste { PasteEdit("ID_main") ;} //検索 ID_search { len = GetEditLength("ID_main") ; if(len <= 0){ SetControlFocus("ID_main") ; return ; } if(GetEditLength("ID_search_buf") == 0){ return ; } st = GetEditCursolStart("ID_main") + 1 ; mx = SearchEditText("ID_main",st,"ID_search_buf") ; if(mx == -1){ MessBox("検索文字列が見つかりません","検索",0,1) ; SetControlFocus("ID_main") ; return ; } SetEditCursol("ID_main",mx , mx+GetEditLength("ID_search_buf")) ; SetControlFocus("ID_main") ; }