'カーソル位置にファイル読込み(履歴つき) / ver. 0.52 / by Kabuneko 2000/05/13
proc main
if @hwnd = 0 then exit proc
dim i, n, f$, key$, file$, line$, path$,
dim item$[40], list$[40], sel
'履歴の数の上限を設定
const limit = 20
'履歴ファイルの指定
f$ = @@QxDirectory$ + "\" + "l_insert.txt"
'ショートカットキー用文字
key$ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
'履歴ファイルを読込む
if dir$(f$) <> "" then
n = 1
open f$ for input as #1
do until eof(1)
lineinput #1, line$
list$[n++] = line$
if n > limit then exit do
loop
close #1
end if
'メニューアイテムの設定
i = 1
item$[i++] = "[ESC] 終了"
item$[i++] = "-"
if mid$(key$,1,1) <> "" then item$[i] = "&" + mid$(key$,1,1) + ". "
item$[i] = item$[i++] + "履歴にないフォルダを選択"
item$[i++] = "-"
for n = 1 to limit
if list$[n] = "" then exit for 'リストが終わるまで追加
'ショートカットキー不足対策
if not n > len(key$) - 1 then item$[i] = "&" + mid$(key$,n+1,1) + ". "
item$[i] = item$[i++] + list$[n]
next
'ポップアップメニューを表示・選択させる
sel = popupmenu(item$)
if sel < 3 then exit proc
'フォルダを選択させてパスを取得
if sel = 3 then
path$ = getfolder$("目的ファイルのあるフォルダを選択")
if path$ = "" then exit proc
end if
'履歴から選択したパスを取得
if sel > 4 then path$ = list$[sel-4]
file$ = GetFileName$(path$, "*.*", "挿入するファイルを選択")
if file$ = "" then exit proc
'フォルダ履歴の書き戻し
for n = 1 to limit
if path$ = list$[n] then list$[n] = ""
next
open f$ for output as #1
print #1, path$
for n = 1 to limit
if list$[n] <> "" then print #1, list$[n]
next
close #1
@Redraw = 0
@UndoBlock = 1
open file$ for input as #1
do until eof(1)
lineinput #1, line$
@Input line$
@CharReturn2
loop
close #1
@CharReturn2
@Redraw = 1
@UndoBlock = 0
print file$ + " を読込みました"
end proc