[HMM0047A] ●特定のファイルを開く - 秀丸エディタQ&A集

Hidemaru Editor

←前へ 次へ→ 機能別Q&A 質問番号順Q&A


[HMM0047A]

●特定のファイルを開く

Q.
指定したファイルが開いてなければ開く、既に開かれていればアクティブにする、というような操作をしたいのですが。

A.

これもさまざまな方法があります。 次の例は、既に開かれているファイル名を調査するタイプのマクロで、常に「MEMO.txt」という文書を編集できる状態にします。

//------- サンプルマクロ -------//

$openFileName = "c:\\hmmac\\MEMO.txt";
if(tolower($openFileName) != filename){
    #findWind = findhidemaru($openFileName);
    if(#findWind > 0)setactivehidemaru #findWind;
    else openfile $openFileName;
}
endmacro;
// ---------------------------- //

秀丸エディタ Ver.8.66以降の場合、「setcompatiblemode」を使う方法もあります。

//------- サンプルマクロ -------//
setcompatiblemode ((compatiblemode & 0xFFFFFF0F) | 0x00000030);
$openFileName = "c:\\hmmac\\MEMO.txt";
if(tolower($openFileName) != filename) openfile $openFileName;
endmacro;
// ---------------------------- //

←前へ 次へ→ 機能別Q&A 質問番号順Q&A