'フォルダリストから開く・保存 / ver. 0.50 / by Kabuneko 2000/05/16
proc main
dim i, n, r, sel, sel2, f$, s$, path$, key$, line$
dim item$[30], item2$[10], list$[20], message$[10]
'履歴ファイルの指定
f$ = @@QxDirectory$ + "\" + "l_dirlst.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 > 20 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 20
if list$[n] = "" then exit for '履歴リストが終わるまで追加
'ショートカットキー不足対策
if not i-3 > len(key$) then item$[i] = "&" + mid$(key$,i-3,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]
'2つめのポップアップメニュー
i = 3
message$[i++] = " からファイルを開く"
message$[i++] = " にこのファイルを保存"
message$[i++] = " を常駐表示"
message$[i++] = " で DOS 窓を開く"
i = 1
item2$[i++] = "[ESC] 終了"
item2$[i++] = "-"
do while message$[i] <> ""
if not i-1 > len(key$) then item2$[i] = "&" + mid$(key$,i-1,1) + ". "
item2$[i] = item2$[i] + path$ + message$[i++]
loop
sel2 = popupmenu(item2$)
if sel2 < 3 then exit proc
'フォルダ履歴の書き戻し
for n = 1 to 20
if path$ = list$[n] then list$[n] = ""
next
open f$ for output as #1
print #1, path$
for n = 1 to 20
if list$[n] <> "" then print #1, list$[n]
next
close #1
path$ = path$ + "\"
'選択したフォルダからファイルを開く
if sel2 = 3 then
@@FileOpenDir path$
'選択したフォルダにこのファイルを保存
elseif sel2 = 4 then
if @hwnd = 0 then exit proc
s$ = inputbox$("《ファイル保存》" + chr$(10) + \
path$ + " に保存します", \
" ◆ フォルダ指定で保存", @FileName$)
if s$ = chr$(&H1B) then exit proc
r = @SaveAs(path$ + s$)
if r = -1 then call msgbox(path$ + s$ + " を保存しました。")
'選択したフォルダを常駐リストで表示
elseif sel2 = 5 then
@@ToolListType = 3
@@ToolListFile$ = path$ + "*.*"
'選択したフォルダの位置で DOS 窓を開く
elseif sel2 = 6 then
chdrive path$ : chdir path$
call shell("command.com", 1)
end if
end proc