'//=========================//
'// 出力ファイル作成 //
'//=========================//
Sub makefile(infname As String, shname As String, outfname As String)
'//=========================//
'// 雛形を読み込む //
'//=========================//
Open infname For Binary Access Read As #1
fsize = FileLen(infname)
Seek #1, 1
indata = Input(fsize, #1)
Close #1
'//=========================//
'// 書き出し内容作成 //
'//=========================//
str_pos = 1 ' 開始ポイント
outdata = ""
tag_pos = InStr(str_pos, indata, "$#$")
no_out_flg = 0 ' IF文初期化
Do While (tag_pos > 0)
'直前まで書き出し
If (no_out_flg = 0) Then
outdata = outdata & Mid(indata, str_pos, tag_pos - str_pos)
End If
'制御内容終わりを探す
end_pos = InStr(tag_pos + 3, indata, "$#$")
If (end_pos = 0) Then
str_pos = tag_pos + 3
Exit Do
End If
'制御内容コピー
tag_data = Mid(indata, tag_pos, end_pos - tag_pos + 3)
' 制御内容ごとに処理
str_pos = chgTagToStr(Replace(tag_data, "$#$", ""), end_pos + 3, shname)
' 次のタグ位置を探す
tag_pos = InStr(str_pos, indata, "$#$")
Loop
' 最後の残りを書き出し
If (no_out_flg = 0) Then
outdata = outdata & Mid(indata, str_pos)
End If
'//=========================//
'// 作成データ書き出し //
'//=========================//
If (Dir(outfname) <> "") Then
Kill outfname ' ファイルがあったら、削除しておく
End If
Open outfname For Binary Access Write As #1
fsize = FileLen(outfname)
Put #1, 1, outdata
Close #1
End Sub
|