$PBExportHeader$u_dfc_base_func.sru forward global type u_dfc_base_func from nonvisualobject end type type ust_ip_option_information from structure within u_dfc_base_func end type type ust_icmp_echo_reply from structure within u_dfc_base_func end type end forward type ust_ip_option_information from structure character ttl character tos character flags character optionssize long optionsdata end type type ust_icmp_echo_reply from structure unsignedlong address unsignedlong status unsignedlong roundtriphome unsignedinteger datasize unsignedinteger reserved unsignedlong datapointer ust_ip_option_information options character data[250] end type global type u_dfc_base_func from nonvisualobject autoinstantiate end type type prototypes end prototypes type variables end variables forward prototypes public function string uf_replaceall (string psreplacestring, string psoldstring, string psnewstring) public function string uf_get_token (ref string pssource, string psseparator) public function boolean uf_split (string pssource, string pssperator, ref string pssplit[]) public function string uf_getkeyvalue (string psstring, string pskey) public function string uf_setkeyvalue (string psstring, string pskey, string psvalue) public function string uf_get_token (ref string pssource, string psseparator, boolean pbremovecomma) public function boolean uf_split (string pssource, string pssperator, ref string pssplit[], boolean pbremovecomma) end prototypes public function string uf_replaceall (string psreplacestring, string psoldstring, string psnewstring);Long dlLen, dlPos, dlStart String dsResult dlLen = Len(psOldString) dsResult = psReplaceString dlStart = 1 DO WHILE TRUE dlPos = Pos(dsResult, psOldString, dlStart) IF dlPos > 0 THEN dsResult = Replace(dsResult, dlPos, dlLen, psNewString) dlStart = dlPos + Len(psNewString) ELSE EXIT END IF LOOP Return dsResult end function public function string uf_get_token (ref string pssource, string psseparator);Return uf_Get_Token(psSource, psSeparator, True) end function public function boolean uf_split (string pssource, string pssperator, ref string pssplit[]);Return uf_Split(psSource, psSperator, psSplit, True) end function public function string uf_getkeyvalue (string psstring, string pskey);String dsKey[] String dsValue[] Integer i psString = uf_ReplaceAll(psString, "~~t", "~t") uf_Split(psString, "~t", dsKey) For i = 1 To UpperBound(dsKey) uf_Split(dsKey[i], "=", dsValue) If UpperBound(dsValue) >= 2 Then If Upper(Trim(dsValue[1])) = Upper(Trim(psKey)) Then Return dsValue[2] End If End If Next Return "" end function public function string uf_setkeyvalue (string psstring, string pskey, string psvalue);String dsKey[] String dsValue[] Integer i Boolean dbFound String dsString psString = uf_ReplaceAll(psString, "~~t", "~t") uf_Split(psString, "~t", dsKey) dbFound = False dsString = "" For i = 1 To UpperBound(dsKey) uf_Split(dsKey[i], "=", dsValue) If dsString <> "" Then dsString += "~t" End If If UpperBound(dsValue) >= 2 Then If Upper(Trim(dsValue[1])) = Upper(Trim(psKey)) Then dbFound = True dsValue[2] = psValue End If dsString += dsValue[1] + "=" If Pos(dsValue[2], "=") > 0 Or Pos(dsValue[2], "~t") > 0 Then If Pos(dsValue[2], '"') = 0 Then dsString += '"' + dsValue[2]+ '"' ElseIf Pos(dsValue[2], "'") = 0 Then dsString += "'" + dsValue[2] + "'" Else MessageBox("出错信息", "调用函数 uf_SetKeyValue 出错!~n~n" + & "关键字: " + dsValue[1] + "~n值: " + dsValue[2] + "~n~n" + & "无法处理值中的等于号(=)!", StopSign!) Return "" End If Else dsString += dsValue[2] End If Else dsString += dsValue[1] End If Next If Not dbFound Then If dsString <> "" Then dsString += "~t" End If dsString += psKey + "=" If Pos(psValue, "=") > 0 Or Pos(psValue, "~t") > 0 Then If (Left(psValue, 1) = "'" And Right(psValue, 1) = "'") Or & Left(psValue, 1) = '"' And Right(psValue, 1) = '"' Then dsString += psValue Else If Pos(psValue, '"') = 0 Then dsString += '"' + psValue + '"' ElseIf Pos(psValue, "'") = 0 Then dsString += "'" + psValue + "'" Else MessageBox("出错信息", "调用函数 uf_SetKeyValue 出错!~n~n" + & "关键字: " + psKey + "~n值: " + psValue + "~n~n" + & "无法处理值中的等于号(=)!", StopSign!) Return "" End If End If Else dsString += psValue End If End If Return dsString end function public function string uf_get_token (ref string pssource, string psseparator, boolean pbremovecomma);// uf_Get_Token // 参数: // psSource: 源串 // psSparator: 分隔符 // pbRemoveComma: 是否去除引号 // 返回: // 分隔符前的串 long p Long dlPos string ret Boolean dbFoundComma1, dbFoundComma2 // p = Pos(psSource, psSeparator) // Get the position of the psSeparator // 查找 psSource 中 psSeparator 的位置 p = 0 dbFoundComma1 = False dbFoundComma2 = False For dlPos = 1 To Len(psSource) If Mid(psSource, dlPos, 1) = '"' Then dbFoundComma1 = Not dbFoundComma1 End If If Mid(psSource, dlPos, 1) = "'" Then dbFoundComma2 = Not dbFoundComma2 End If If Mid(psSource, dlPos, 1) = psSeparator Then If Not dbFoundComma1 And Not dbFoundComma2 Then p = dlPos Exit End If End If Next if p = 0 then // if no psSeparator, ret = psSource // return the whole psSource string and psSource = "" // make the original psSource of zero length else ret = Mid (psSource, 1, p - 1) // otherwise, return just the token and psSource = Mid (psSource, p + Len ( psSeparator )) // strip it & the psSeparator end if ret = Trim(ret) ret = uf_ReplaceAll(ret, "''", "'") ret = uf_ReplaceAll(ret, '""', '"') If pbRemoveComma Then If Left(ret, 1) = Right(ret, 1) And & (Left(ret, 1) = "'" Or Left(ret, 1) = '"') Then ret = Mid(ret, 2, Len(ret) - 2) End If End If return ret end function public function boolean uf_split (string pssource, string pssperator, ref string pssplit[], boolean pbremovecomma);// uf_Split // 参数 // psSource // psSperator // psSpilt // pbRemoveComma: 去除引号 Integer i Boolean dbFound // 判断 psSource 的最后是否是分隔符, 如果是, 则在最后添加一个空值 If Right(psSource, Len(psSperator)) = psSperator Then dbFound = True Else dbFound = False End If i = 0 Do While psSource <> "" i ++ psSplit[i] = Trim(uf_Get_Token(psSource, psSperator, pbRemoveComma)) Loop // 如果最后一个值是分隔符, 则添加一个空值在最后 If dbFound Then i ++ psSplit[i] = "" End If Return True end function on u_dfc_base_func.create call super::create TriggerEvent( this, "constructor" ) end on on u_dfc_base_func.destroy TriggerEvent( this, "destructor" ) call super::destroy end on