LoginSignup
1
1

More than 5 years have passed since last update.

シナリオからteratermマクロを作りたい

Posted at

/*シナリオファイル名入力*/
regexoption "SJIS"
inputbox "input scenario file name" "scenario file name"
sce_file = inputstr
strmatch sce_file '\S.*\.scenario$'
if result = 1 then
messagebox sce_file "scenario filename accepted"
else
messagebox "bye!" "scenario filename denied"
endif

/*TTLファイル名決定*/
ttl_file = sce_file
strreplace ttl_file 1 '.scenario$' '.ttl'
messagebox ttl_file "scenario filename denied"

/*シナリオファイルオープン、TTLファイル作成*/
fileopen HDL_sce sce_file 0
filecreate HDL_ttl ttl_file

/*タグ定義*/
keyword_logwrite = 'logwrite'
keyword_sendln = 'sendln'
keyword_notouch = 'notouch'
TAG_NUM = 0

/*主処理*/

while 1
/*ファイル最後ならbreak*/
filereadln HDL_sce line
if result = 1 then
break
endif
/*TAG決定*/
strmatch line keyword_logwrite
if result=1 TAG_NUM=1
strmatch line keyword_sendln
if result=1 TAG_NUM=2
/*ファイル書き込み処理*/
if TAG_NUM=0 then
strmatch line keyword_notouch
if result=1 then
strreplace line 1 keyword_notouch ""
filewriteln HDL_ttl line
else
filewriteln HDL_ttl line
endif
elseif TAG_NUM=1 then
strmatch line keyword_notouch
if result=1 then
strreplace line 1 keyword_notouch ""
filewriteln HDL_ttl line
else
strmatch line keyword_logwrite
if result=1 filewriteln HDL_ttl "#13#10"
newline = "logwrite "#39
strconcat newline line
strconcat newline #39
strconcat newline "#13#10
filewriteln HDL_ttl newline
endif
elseif TAG_NUM=2 then
strmatch line keyword_notouch
if result=1 then
strreplace line 1 keyword_notouch ""
filewriteln HDL_ttl line
else
strmatch line keyword_sendln
if result=1 then
newline = "logwrite "#39
strconcat newline line
strconcat newline #39
strconcat newline "#13#10"
filewriteln HDL_ttl newline
filewriteln HDL_ttl "sendln "#39#39
else
filewriteln HDL_ttl "pause 1"
newline = "sendln "#39
strconcat newline line
strconcat newline #39
filewriteln HDL_ttl newline
endif
endif
endif
endwhile

/*ファイルクローズ、終了*/
fileclose HDL_sce
fileclose HDL_ttl
end

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1