'カーソル位置単語からファイルを開く / Ver. 0.61 / by Kabuneko 2000/07/29
proc main
if @hwnd=0 then exit proc
dim i, word$, file$, name$, path$, find1, find2
'選択されていれば、その文字列を使う
if @Select > 0 then
word$ = @TextSelect$
@Select = 0
'選択されていないとき、文字種指定で単語を取得
else
word$ = @GetCursorWord3$(":#@.~-_/!?\|")
end if
'ラベルを切り分け
i = instr(word$, "#")
if i > 0 then
file$ = mid$(word$, 1, i-1)
name$ = mid$(word$, i+1)
else
file$ = word$
name$ = ""
end if
'別ファイルを開く場合
if file$ <> "" then
if dir$(file$) <> "" then 'ファイルの存在をチェック
call @@OpenFile(file$)
else
'カレントディレクトリにないときは、カレントファイルのパスで探す
path$ = left$(@Pathname$, inrstr(@Pathname$, "\"))
if dir$(path$ + file$) <> "" then 'ファイルの存在をチェック
call @@OpenFile(path$ + file$)
else
print cformat$("%s というファイルがみつかりません",file$)
exit proc
end if
end if
end if
'ラベル指定のとき、ファイル内で移動
if name$ = "" then exit proc
find1 = @@FindCaseSensitive
find2 = @@FindLongestMatch
'正規表現による検索; 文字列の指定は正規表現で
@@FindRegExp = 1
@@FindRegExp = -2
@@FindCaseSensitive = 0
@@FindLongestMatch = 0
@Redraw = 0
@MoveFileTop
'ここからファイルタイプによって分岐; elseif で分岐追加可
'HTML ファイルの場合
if instr(file$, ".htm") > 0 or instr(file$, ".HTM") then
@FindStringBottom "<a +name *= *""?" + name$ + """? *>"
'それ以外のファイルの場合; カッコの指定は変更可
else
@FindStringBottom "[【[\[] *" + name$ + " *[】]\]]"
end if
@Redraw = 1
if @@SearchFound = 0 then
print cformat$("ラベル [ %s ] がありません",name$)
end if
@@FindCaseSensitive = find1
@@FindLongestMatch = find2
end proc