************************************************************/"
FunName = 2 '放置函数名的行
RetrunType = 9 '放置函数类型的行
Parameters = 7 '放置参数列表的起始行
History = 16 '放置History的行
With ActiveDocument.Selection ' Get function info
text = trim(.text)
if text = "" then exit sub
ReplaceAll text, vbTab, " "
if GetStringBetween(text, "", "(") = "" then exit sub
ParseToArray GetStringBetween(text, "", "("), " ", tmp, TRUE
if UBound(tmp) = 0 then exit sub
strFunName = tmp(UBound(tmp))
For i=0 to UBound(tmp) - 1
strFunType = strFunType + tmp(i) + " "
Next
ParseToArray GetStringBetween(text, "(", ")"), ",", strParms, TRUE
.StartOfLine
.NewLine
.LineUp
.Text = desc(0)
for line = 1 to UBound(desc)
.NewLine
.StartOfLine
if line = FunName then
.text = desc(line) + strFunName
elseif line = RetrunType then
.text = desc(line) + strFunType
elseif line = Parameters then
dim MaxLen, MaxTab
for i = 0 to UBound(strParms)
strParms(i) = Trim(strParms(i))
if MaxLen < len(strParms(i)) then
MaxLen = len(strParms(i))
end if
next
MaxTab = MaxLen \ docTab
for i=0 to UBound(strParms) - 1
.text = desc(line) + strParms(i) + string(MaxTab - (len(strParms(i)) \ docTab), vbTab) + vbTab + "[in / out] - "
.NewLine
.StartOfLine dsFirstColumn
next
.text = desc(line) + strParms(i) + string(MaxTab - (len(strParms(i))\docTab), vbTab) + vbTab + "[in / out] - "
elseif line = History then
.text = desc(line)
.text = FormatDatetime(Date, vbShortDate)
.text = + vbTab + vbTab + Author + vbTab + vbTab + "Created"
else
.text = desc(line)
end if
next
end With
End Sub
Function ParseToArray(ByVal as_source, ByVal as_delimiter, as_array(), bPreventRepeat)
Dim ll_DelLen, ll_Pos, ll_Count, ll_Start, ll_Length
Dim ls_holder
'Check for NULL
If IsNull(as_source) Or IsNull(as_delimiter) Then
ParseToArray = Null
End If
'Check for at leat one entry
If Trim(as_source) = "" Then
ParseToArray = 0
End If
'Get the length of the delimeter
ll_DelLen = Len(as_delimiter)
ll_Pos = InStr(UCase(as_source), UCase(as_delimiter))
'Only one entry was fo
und
If ll_Pos = 0 Then
ReDim as_array(0)
as_array(0) = as_source
ParseToArray = 1
End If
'More than one entry was found - loop to get all of them
ll_Count = -1
ll_Start = 1
Do While ll_Pos > 0
'Set current entry
ll_Length = ll_Pos - ll_Start
If Not bPreventRepeat Or ll_Length > 0 Then
ls_holder = Mid(as_source, ll_Start, ll_Length)
' Update array and counter
ll_Count = ll_Count + 1
ReDim Preserve as_array(ll_Count)
as_array(ll_Count) = ls_holder
Else
End If
'Set the new starting position
ll_Start = ll_Pos + ll_DelLen
ll_Pos = InStr(ll_Start, UCase(as_source), UCase(as_delimiter))
Loop
'Set last entry
ls_holder = Mid(as_source, ll_Start, Len(as_source))
' Update array and counter if necessary
If Len(ls_holder) > 0 Then
ll_Count = ll_Count + 1
ReDim Preserve as_array(ll_Count)
as_array(ll_Count) = ls_holder
End If
'parsetoarray = the number of entries found
ParseToArray = ll_Count
End Function
Function GetStringBetween(ByVal str, ByVal strStart, ByVal strEnd)
Dim pos1, pos2, pos
If str = "" then
GetStringBetween = ""
Exit Function
End If
If s