#5062

xxx_pic
Member

use a marco to do it!


#language = "VBScript"
'############################################################
'* Name: Open This File V1.0 For EmEditor Pro v6 Marco
'* Date: 2007-11-28
'############################################################

On Error Resume Next
sText = document.selection.Text

If Len(sText)=0 Then
'Check if is ASP's INCLUDE FILE
xPos = document.selection.GetActivePointX(eePosLogical)
yPos = document.selection.GetActivePointY(eePosLogical)
document.selection.SelectLine
sText = document.selection.Text

Set regEx = New RegExp
regEx.Pattern = "<!--s*#INCLUDEs*FILEs*=s*""(.+)""s*-->"
regEx.IgnoreCase = True
If regEx.Test(sText) Then sText=regEx.Replace(sText,"$1")
sText=Replace(sText,vbCrLf,"")
sText=Replace(sText,vbCr,"")
sText=Replace(sText,vbLf,"")

document.selection.SetActivePoint eePosLogical, xPos, yPos

Set fso = CreateObject("Scripting.FileSystemObject")

fPath = Left(document.FullName,InstrRev(document.FullName,""))
sText = fPath & Replace(sText,"/","")
If fso.FileExists(sText) Then editor.OpenFile sText,0,eeOpenAllowNewWindow

Set fso=Nothing
Set regEx=Nothing

Else
'Check if is local hard disk address (C:abc1.txt) or network address (abc1.txt)

Set fso = CreateObject("Scripting.FileSystemObject")

Set regEx = New RegExp
regEx.Pattern = "^(?:[A-Z]:|\)[^s]"
regEx.IgnoreCase = True
If regEx.Test(sText) Then
'absolute address
If fso.FileExists(sText) Then editor.OpenFile sText,0,eeOpenAllowNewWindow
Else
'relative address
fPath = Left(document.FullName,InstrRev(document.FullName,""))
sText = fPath & Replace(sText,"/","")
If fso.FileExists(sText) Then editor.OpenFile sText,0,eeOpenAllowNewWindow
End If

Set fso=Nothing
Set regEx=Nothing

End If