'指定フォルダのマクロをリスト / ver. 0.51 / by Kabuneko 2000/03/04
proc main
dim i, ret, sel, f$, file$, path$, item$[30]
dim m$, macro$[300], line$, list$[300], proc$[50]
'履歴ファイルの指定
f$ = @@QxDirectory$ + "\" + "l_macdir.txt"
'メニューアイテムの設定
i = 1
item$[i++] = "終了"
item$[i++] = "-"
item$[i++] = "べつのフォルダを選択"
'履歴ファイルあれば履歴を読込み(20個まで)
if dir$(f$) <> "" then
item$[i++] = "-"
open f$ for input as #1
do until eof(1)
lineinput #1, line$
item$[i++] = line$
if i > 24 then exit do
loop
close #1
end if
'ポップアップメニューを表示・選択させる
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$ = item$[sel]
'フォルダ履歴の書き戻し
for i = 5 to 25
if path$ = item$[i] then item$[i] = ""
next
open f$ for output as #1
item$[4] = path$
for i = 4 to 24
if item$[i] <> "" then print #1, item$[i]
next
close #1
'目的のフォルダにあるマクロファイルをリスト
i = 1
m$ = dir$(path$ + "\*.mac")
do while m$ <> ""
macro$[i++] = m$
m$ = dir$()
loop
if macro$[1] = "" then
call msgbox("このフォルダにはマクロはありません。")
exit proc
end if
'マクロとコメントのリストをつくる
i = 1
do while macro$[i] <> ""
file$ = path$ + "\" + macro$[i]
open file$ for input as #1
lineinput #1, line$
list$[i] = macro$[i]
if left$(line$, 1) = "'" then \
list$[i] = list$[i] + " : " + mid$(line$, 2)
i = i + 1
close #1
loop
dialog path$ + " マクロファイル一覧", 30, 20, 400, 300, 0, "MS ゴシック", 100
CONTROL "マクロファイルを選択してください", -1, "STATIC", SS_LEFT, 10, 5, 300, 8
CONTROL "", 100, "LISTBOX", LBS_SORT | WS_BORDER | WS_VSCROLL | WS_TABSTOP, 10, 20, 380, 260
CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_TABSTOP, 75, 280, 70, 14
CONTROL "ファイルを開く", 200, "BUTTON", BS_DEFPUSHBUTTON | WS_TABSTOP, 165, 280, 70, 14
CONTROL "キャンセル", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_TABSTOP, 255, 280, 70, 14
dlglistboxarray 100, list$
do while 1
ret = dialog(1 | DLGN_SELCHANGE | DLGN_DOUBLECLICKED)
file$ = path$ + "\"
if instr(DlgText$(100), " : ") > 0 then
file$ = file$ + mid$(DlgText$(100), 1, instr(DlgText$(100), " : "))
else
file$ = file$ + DlgText$(100)
end if
if ret = IDOK and DlgText$(100) <> "" then
exit do
elseif ret = 200 and DlgText$(100) <> "" then
call dialog(0)
call @@OpenFile(file$)
exit proc
elseif ret = IDCANCEL then
exit proc
end if
loop
call dialog(0) 'ダイアログ表示を終了
open file$ for input as #1
i = 1
do until eof(1)
lineinput #1, line$
if lcase$(left$(line$, 5)) = "proc " then
proc$[i++] = mid$(line$, 6)
end if
loop
close #1
dialog file$ + " プロシージャ一覧", 60, 60, 240, 200, 0, "MS ゴシック", 100
CONTROL "プロシージャを選択してください", -1, "STATIC", SS_LEFT, 10, 5, 200, 8
CONTROL "", 100, "LISTBOX", WS_BORDER | WS_VSCROLL | WS_TABSTOP, 10, 20, 220, 150
CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_TABSTOP, 50, 180, 60, 14
CONTROL "キャンセル", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_TABSTOP, 130, 180, 60, 14
dlglistboxarray 100, proc$
do while 1
ret = dialog(1 | DLGN_SELCHANGE | DLGN_DOUBLECLICKED)
if ret = IDOK and DlgText$(100) <> "" then
m$ = DlgText$(100)
i = instr(m$, " ")
if i = 0 then i = instr(m$, chr$(&h09))
if i = 0 then i = instr(m$, "'")
if i > 0 then m$ = left$(m$, i)
if right$(m$, 2) = "()" then
m$ = left$(m$, len(m$)-2)
end if
exit do
elseif ret = IDCANCEL then
exit proc
end if
loop
call dialog(0) 'ダイアログ表示を終了
'選択されたプロシージャを実行
@@JumpMacro file$ + "," + m$
end proc