|
AE86さん,こんにちは。
》簡単なNC文(機械を動作させる文)を紹介します
この種のプログラム始めて見ました。
理解できたかどうかわかりませんが,次のようなマクロでいかがでしょう。
置換する文字がこの例であげられたものに固定されていれば,もっと短くするこ
ともできますが,後の応用がきくように置換を並べるようにしましたので,長いも
のになってしました。必要に応じてマクロ最後の部分を書き換えることができます。
》 アウトルックにて本文を作成した後、秀丸で読んだら
》 秀丸の見やすさが 再認識できました。
この際,秀丸と兄弟分である鶴亀メールも試されてみたらいかがでしょう。
秀丸に慣れた方なら見やすいのでは。秀丸ユーザであれば無料ですよ(^^;
では, (^^)/~
山紫水明
//------------ OutKakkoRep.mac -------------------------------//
// 座標変換マクロ (括弧内を除いて置換する)
menu
"&1 +90度座標変換",
"&2 -90度座標変換",
"&3 Y軸対称座標変換",
"&4 X軸対称座標変換";
#r = result;
if( #r == 0 ) endmacro;
call Change_search;
//showwindow 0;
//これを有効にすると,ウィンドウを隠してスピードアップします。
disabledraw;
gofileend;
#i = 0;
while( 1 ) {
searchup "[((][^))]*[))]", regular;
if( !result ) break;
#i = #i + 1;
cut;
insert "@^[" + str(#i) + "]^@";
//文書中では現れる可能性のない適当な文字列に置き換え
}
#handle1 = hidemaruhandle(0);
#n = #i;//データ数
openfile "/h temp.tmp"; //ステルスファイルに移動
#handle2 = hidemaruhandle(0);
while( #i ) {
poppaste;
#i = #i - 1;
insertreturn;
}
#i = 1;
gofiletop;
while( #i <= #n ) {
beginsel;
golineend2;
$s[#i] = gettext(seltopx, seltopy, selendx, selendy);
#i = #i + 1;
movetolineno 1, lineno + 1;
}
setactivehidemaru #handle1;
call Replace;
gofileend;
#i = 1;
while( #i <= #n) { //文字列の復帰
searchup "@^[" + str(#i) + "]^@";
insert $s[#n - #i + 1];
#i = #i + 1;
}
closehidemaruforced #handle2;
call Reset_search;
endmacro;
Change_search: //検索状態を変更
if (!searchmode) { // 検索状態を範囲選択に変更
openreg "CURRENTUSER", "Software\\Hidemaruo\\Hidemaru\\Env";
writeregnum "SelectFound",1;
#modechanged = 1;
envchanged;
}
#searchoption = searchoption;
$searchbuffer = searchbuffer;
return;
Reset_search: //検索状態を元に戻す
if (#modechanged) {
writeregnum "SelectFound",#s_mode;
envchanged;
closereg;
}
setsearch $searchbuffer, #searchoption;
return;
Replace: //置換の実行
if( #r == 1 ) call Replace_1;
else if( #r == 2 ) call Replace_2;
else if( #r == 3 ) call Replace_3;
else call Replace_4;
return;
//**********************************************
/////必要あればこれ以下を訂正する /////
Replace_1: //90度座標変換
replaceallfast "X","あ";
replaceallfast "Y-","い";
replaceallfast "Y","う";
replaceallfast "I","え";
replaceallfast "J-","お";
replaceallfast "J","か";
replaceallfast "あ","Y";
replaceallfast "い","X";
replaceallfast "う","X-";
replaceallfast "え","J";
replaceallfast "お","I";
replaceallfast "か","I-";
return;
Replace_2: //-90度座標変換
replaceallfast "X-","あ";
replaceallfast "X","い";
replaceallfast "Y","う";
replaceallfast "I-","え";
replaceallfast "I","お";
replaceallfast "J","か";
replaceallfast "あ","Y";
replaceallfast "い","Y-";
replaceallfast "う","X";
replaceallfast "え","J";
replaceallfast "お","J-";
replaceallfast "か","I";
return;
Replace_3: //Y軸対称座標変換
replaceallfast "X-","あ";
replaceallfast "X","い";
replaceallfast "I-","う";
replaceallfast "I","え";
replaceallfast "G02","お";
replaceallfast "G03","か";
replaceallfast "G41","き";
replaceallfast "G42","く";
replaceallfast "あ","X";
replaceallfast "い","X-";
replaceallfast "う","I";
replaceallfast "え","I-";
replaceallfast "お","G03";
replaceallfast "か","G02";
replaceallfast "き","G42";
replaceallfast "く","G41";
return;
Replace_4: //X軸対称座標変換
replaceallfast "Y-","あ";
replaceallfast "Y","い";
replaceallfast "J-","う";
replaceallfast "J","え";
replaceallfast "G02","お";
replaceallfast "G03","か";
replaceallfast "G41","き";
replaceallfast "G42","く";
replaceallfast "あ","Y";
replaceallfast "い","Y-";
replaceallfast "う","I";
replaceallfast "え","I-";
replaceallfast "お","G03";
replaceallfast "か","G02";
replaceallfast "き","G42";
replaceallfast "く","G41";
return;
//----------------------------------------------------------------//
|
|