Imports EnvDTE
Imports System.Diagnostics
Public Module InterPreter
REM 提取函数名称
Function GetFuncName(szStr as String)
Dim szTmp, szFunc
Dim ulPos, ulLen
Dim szTmpStr
szTmpStr = Trim(szStr)
szFunc = 0
If Trim(szTmpStr) <> "" Then
ulPos = InStr(Trim(szTmpStr), "(")
szTmp = Trim(Left(szTmpStr, ulPos - 1))
ulLen = Len(szTmp)
ulPos = InStrRev(szTmp, " ")
szFunc = Right(szTmp, ulLen - ulPos)
Else
szFunc = ""
End If
GetFuncName = szFunc
End Function
REM 输出函数头
Sub FunctionHeader()
Dim szTmp, szStr
szTmp = DTE.ActiveDocument.Selection.Text
szStr = "" _
& "/******************************************************************************* " & vbCrLf & "" _
& "* Function name : " & GetFuncName(szTmp) & vbCrLf & "" _
& "* Description : " & vbCrLf & "" _
& "* Arguments : " & vbCrLf & "" _
& "* Return value : " & vbCrLf & "" _
& "* Author : HCJ " & vbCrLf & "" _
& "* Date: " & Year(Now) & "-" & Month(Now) & "-" & Day(Now) & vbCrLf & "" _
& "*******************************************************************************/ " & vbCrLf
DTE.ActiveDocument.Selection.StartOfLine()
DTE.ActiveDocument.Selection.Text = szStr
End Sub
REM 输出文件头
Sub FileHeader()
DTE.ActiveDocument.Selection.StartOfDocument()
DTE.ActiveDocument.Selection.Text = "" _
& "/********************************************************************************** " & vbCrLf & "" _
& "* File name : " & DTE.ActiveDocument.Name & vbCrLf & "" _
& "* Description : " & vbCrLf & "" _
& "* Author : HCJ " & vbCrLf & "" _
& "* Copyright (c) 2005-" & Year(Now) & vbCrLf & "" _
& "* Version : 0.1 " & vbCrLf & "" _
& "* Date : " & Year(Now) & "-" & Month(Now) & "-" & Day(Now) & vbCrLf & "" _
& "**********************************************************************************/ " & vbCrLf
End Sub
REM 输出类头
Sub ClassHeader()
DTE.ActiveDocument.Selection.Text = "" _
& "/******************************************************************************* " & vbCrLf & "" _
& "* Class name : " & vbCrLf & "" _
& "* Description : " & vbCrLf & "" _
& "* Interface : " & vbCrLf & "" _
& "* Call : " & vbCrLf & "" _
& "* Author : HCJ " & vbCrLf & "" _
& "********************************************************************************/ " & vbCrLf
End Sub
End Module