
Function DeleteTrim(ByVal strSource)
	DeleteTrim = Trim(strSource)
End Function

Function SeprateString(ByRef strChar, ByVal strseprator)
    Dim intPos
    Dim sValue
    Dim I
    Dim nYHCount
    nYHCount = 0
    If InStr(strChar, strseprator) = 0 Then
        SeprateString = strChar
        strChar = ""
        Exit Function
    End If
    If strseprator = "=" Then
        sValue = strChar
        For I = 1 To Len(sValue)
            If Mid(sValue, I, 1) = "=" Then
                If (nYHCount Mod 2) = 0 Then
                    SeprateString = Left(strChar, I - 1)
                    strChar = Mid(strChar, I + Len(strseprator))
                    Exit Function
                End If
            ElseIf Mid(sValue, I, 1) = """" Then
                nYHCount = nYHCount + 1
            End If
        Next
        SeprateString = strChar
        strChar = ""
    Else
        intPos = InStr(strChar, strseprator)
        SeprateString = Left(strChar, intPos - 1)
        strChar = Mid(strChar, intPos + Len(strseprator))
    End If  
End Function

Function IsMyField(ByVal strChar, ByVal IsField)
    Dim strFF

    strChar= Ucase(strChar)
    strFF = "Country,ComName,ProductName,SunwayClass,SunwayClassName,Keyword,strRemark,Introduce,strFileType,strComName,strProName,任意字段"
    If Trim(strChar) = "" Then
        IsMyField = False
        Exit Function
    End If
    If Not IsField Then strFF = "G,C,P,R,S,K,N,M,F,L,Q,U"

    IsMyField = CBool(InStr("," & strFF & ",", "," & Trim(strChar) & ","))
End Function
Function IsMyRelation(ByVal strChar)
    If Trim(strChar) = "" Then
        IsMyRelation = False
        Exit Function
    End If

    If InStr(",=,>,<,>=,<=,<>,", "," & Trim(strChar) & ",") >0 then
		IsMyRelation = True
    Else
		IsMyRelation = False
    End If
End Function
Function IsBracket(ByVal strChar)
    If Trim(strChar) = "" Then
        IsBracket = False
        Exit Function
    End If
    IsBracket = CBool(InStr(",),(,", "," & Trim(strChar) & ","))
End Function
Function TransField(ByVal strChar)
    Dim strMid
    Dim blnBracket

    if LEFT(strChar,1)="(" then
    	blnBracket = True
    Else
    	blnBracket = False
    End If

    If blnBracket Then
        strMid = Trim(Mid(UCase(strChar), 2))
    Else
        strMid = UCase(Trim(strChar))
    End If
    Select Case strMid
    case "F"        '附件类型
    	TransField = "strFileType" 
    case "G"        '国别
    	TransField = "Country"    
    case "C"        '公司名称
    	TransField = "ComName"
    case "L"        '公司名称
    	TransField = "strComName"
    Case "P"        '产品名称
        TransField = "ProductName"
    Case "Q"        '产品名称
        TransField = "strProName"
    case "R"        '分类
        TransField = "SunwayClass"
    Case "S"        '分类
        TransField = "SunwayClassName"
    Case "K"        '关键词
        TransField = "Keyword"        
    Case "M"        '产品介绍
        TransField = "Introduce"
    case "N"        '产品介绍
        TransField = "strRemark"    
    Case "U"	    '任意字段
        TransField = "任意字段"
    End Select

    If blnBracket Then
        TransField = "(" & TransField
    End If
End Function
Function TransSearchDoor(ByVal strField)
    Select Case Ucase(strField)
    case "ComName"
    	TransSearchDoor = "C"
    case "Country"
    	TransSearchDoor = "G"
    case "strFileType"
    	TransSearchDoor = "F"
    Case "ProductName"
        TransSearchDoor = "P"
    Case "strProName"
        TransSearchDoor = "Q"
    Case "SunwayClass"
        TransSearchDoor = "R"
    case "SunwayClassName"
        TransSearchDoor = "S"
    Case "Keyword"
        TransSearchDoor = "K"
    case "strComName"
        TransSearchDoor = "L"
    Case "Introduce"
    	TransSearchDoor = "M"
    Case "strRemark"
        TransSearchDoor = "N"    
    Case "任意字段"
        TransSearchDoor = "U"
    End Select
End Function

Function GetSubStr(ByRef strSource, ByRef strFlag, ByVal intIsLogic)
    Dim intPos
    Dim strMid
    Dim strLogic

    If intIsLogic = 1 Then
        strLogic = "*,+,-,=,>,<,>=,<=,<>,(,)"
    ElseIf intIsLogic = 2 Then
        strLogic = "=,>,<,>=,<=,<>"
    ElseIf intIsLogic = 3 Then
        strLogic = "(,)"
    ElseIf intIsLogic = 4 Then
        strLogic = "*,+,-"
    End If

    For intPos = 1 To Len(strSource)
        strMid = Mid(strSource, intPos, 1)

        If InStr(strLogic, strMid) > 0 Then
            If strMid = ">" Or strMid = "<" Then
                If InStr("=,>", Mid(strSource, intPos + 1, 1)) > 0 Then
                    strMid = Mid(strSource, intPos, 2)
                    GetSubStr = Left(strSource, intPos)
                    strSource = Mid(strSource, intPos + 3)
                    strFlag = strMid
                Else
                    GetSubStr = Left(strSource, intPos)
                    strSource = Mid(strSource, intPos + 1)
                    strFlag = strMid
                End If
            Else
                GetSubStr = Left(strSource, intPos - 1)
                strSource = Mid(strSource, intPos + 1)
                strFlag = strMid
            End If
            Exit function
        End If
    Next
    GetSubStr = strSource
    strSource = ""
    strFlag = ""
End Function

Function AddShow(ByVal strText,ByVal strEntry)
    Dim strMid,strFlag,strBracket,str1
    If Len(strText) <= 2 Then
        AddShow = strEntry & "=" & strText
    else
    	strMid = GetSubStr(strText, strFlag, 2)
    	str1 = Left(strMid, 1)
    	Do While str1 = "("
        	strBracket = strBracket & str1

        	strMid = Mid(strMid, 2)

        	str1 = Left(strMid, 1)
    	Loop
    	If IsMyField(strMid, False) Then
        	AddShow = strBracket & strMid & strFlag & strText
    	Else
        	AddShow = strEntry & "=" & strBracket & strMid & strFlag & strText
    	End if    
    End if
    
    AddShow = Replace(AddShow,"G=","国别=")
    AddShow = Replace(AddShow,"F=","附件类型=")
    AddShow = Replace(AddShow,"C=","企业名称=")
    AddShow = Replace(AddShow,"P=","产品名称=")
    AddShow = Replace(AddShow,"Q=","产品名称=")
    AddShow = Replace(AddShow,"R=","分类=")
    AddShow = Replace(AddShow,"S=","分类名=")
    AddShow = Replace(AddShow,"K=","关键词=")
    AddShow = Replace(AddShow,"L=","企业名称=")
    AddShow = Replace(AddShow,"M=","产品简介=")
    AddShow = Replace(AddShow,"N=","产品简介=")
    AddShow = Replace(AddShow,"U=","任意字段=")
End Function

Function AddField(ByVal strText,ByVal strEntry)
    Dim strMid,strFlag,strBracket,str1
    If Len(strText) <= 2 Then
        AddField = strEntry & "=" & strText
        Exit Function
    End If
    strMid = GetSubStr(strText, strFlag, 2)
    str1 = Left(strMid, 1)
    Do While str1 = "("
        strBracket = strBracket & str1

        strMid = Mid(strMid, 2)

        str1 = Left(strMid, 1)
    Loop
    If IsMyField(strMid, False) Then
        AddField = strBracket & strMid & strFlag & strText
    Else
        AddField = strEntry & "=" & strBracket & strMid & strFlag & strText
    End If
End Function
function IsOperation(byval sChar)
   dim sXX
   
   sXX = ",*,+,-,"
   sChar = "," & sChar & ","
   IsOperation = (Instr(sXX,sChar)>0)
end function
Function GetRigorExpress(ByVal sChar,byval bRigor)
    If sChar = "" Then Exit Function
    
    Dim I,J,bFound,strMid,strNewChar
    
    J = 1
    strMid = Mid(sChar, J, 1)
    Do While IsBracket(strMid) Or IsMyRelation(strMid) Or IsOperation(strMid)
        strMid = Mid(sChar, J, 1)
        J = J + 1
    Loop
    
    If J = 1 Then J = J + 1
    J = J - 1 - 1
    if bRigor then
    	strNewChar = Left(sChar, J) & "["
    else
    	strNewChar = Left(sChar, J) & ""
    end if
    bFound = False
    For I = J + 1 To Len(sChar)
        strMid = Mid(sChar, I, 1)
        
        If IsBracket(strMid) Or IsMyRelation(strMid) Or IsOperation(strMid) Then
            If Not bFound Then
            	if bRigor then
                	strNewChar = strNewChar & "]" & strMid
                else
                	strNewChar = strNewChar & "" & strMid
                end if
            Else
                strNewChar = strNewChar & strMid
            End If
            
            bFound = True
        Else
            If bFound Then
            	if bRigor then
                	strNewChar = strNewChar & "[" & TRIM(strMid)
                else
                	strNewChar = strNewChar & "" & strMid
                end if
            Else
                strNewChar = strNewChar & strMid
            End If
            bFound = False
        End If
    Next
    If Not bFound Then
    	if bRigor then
        	strNewChar = strNewChar & "]"
        else
        	strNewChar = strNewChar & ""
        end if
    End If
    
    GetRigorExpress = strNewChar
End Function

Function GetBlueValue(ByVal sValue)
Dim nLeftBracketCount, nRightBracketCount
Dim sTempValue
Dim I, nPos
Dim IsInYH

If sValue = "" Then
    GetBlueValue = ""
    Exit Function
End If

sValue = Trim(sValue)

nLeftBracketCount = 0: nRightBracketCount = 0
IsInYH = false
For I = 1 To Len(sValue)
    If Mid(sValue, I, 1) = "(" Then
        If not IsInYH Then
            nLeftBracketCount = nLeftBracketCount + 1
        End If
    ElseIf Mid(sValue, I, 1) = ")" Then
        If not IsInYH Then
            nRightBracketCount = nRightBracketCount + 1
        End if
    ElseIf Mid(sValue, I, 1) = """" then
    	if IsInYH then
    		IsInYH = false
    	else
    		IsInYH = true
    	end if
    End If
Next

If nLeftBracketCount <> nRightBracketCount Then
    If nLeftBracketCount > nRightBracketCount Then
        For I = 1 To (nLeftBracketCount - nRightBracketCount)
            nPos = InStr(sValue, "(")
            sValue = Left(sValue, nPos - 1) & Mid(sValue, nPos + 1)
        Next
    Else
        sValue = StrReverse(sValue)
        For I = 1 To (nRightBracketCount - nLeftBracketCount)
            nPos = InStr(sValue, ")")
            sValue = Left(sValue, nPos - 1) & Mid(sValue, nPos + 1)
        Next
    	sValue = StrReverse(sValue)
    End if
    sValue = Trim(sValue)
	Do While IsBracket(Left(sValue, 1))
		sValue = Trim(Mid(sValue, 2))
	Loop
	Do While IsBracket(Right(sValue, 1))
		sValue = Trim(Left(sValue, Len(sValue) - 1))
	Loop
End If

sValue = Trim(sValue)
Do While IsOperation(Left(sValue, 1)) Or IsMyRelation(Left(sValue, 1))
sValue = Trim(Mid(sValue, 2))
Loop
Do While IsOperation(Right(sValue, 1)) Or IsMyRelation(Right(sValue, 1))
sValue = Trim(Left(sValue, Len(sValue) - 1))
Loop
GetBlueValue = Trim(sValue)
End Function

Private Function IssnCondition(ByVal strISSN,byval strFind)
    Dim strTemp, strMid, strLeft, strRight
    Dim intIssnPos
    Dim intNextFldPos
    Dim intPos, intStart
    Dim strMidLeft, strMidRight
    '处理ISSN,CNNO
    'intIssnPos = InStr(strISSN, "I=")
    intIssnPos = InStr(strISSN, strFind)
    If intIssnPos > 0 Then
        intNextFldPos = InStr(intIssnPos + 2, strISSN, "=")
        If intNextFldPos = 0 Then
            strMid = Mid(strISSN,intIssnPos)
            
            strLeft = Left(strISSN, intIssnPos - 1)
            strRight = ""
        Else
            strMid = Mid(strISSN, intIssnPos, intNextFldPos - intIssnPos - 1 - 1)
            strLeft = Left(strISSN, intIssnPos - 1)
            strRight = Mid(strISSN, intNextFldPos - 1 - 1)
        End If
        
        intStart = 1
        intPos = InStr(intStart, strMid, "-")
        Do while intPos > 0
	        If intPos Mod 2 = 1 Then
	            strMid = Left(strMid, intPos - 1) & "Y" & Mid(strMid, intPos + 1)
	            intStart = intPos + 1
	        Else
                    intStart = intPos + 1
	        End If
	        
	        intPos = InStr(intStart, strMid, "-")
	Loop
	IssnCondition = strLeft & strMid & strRight
    Else
        IssnCondition = strISSN
    End If
End Function

function GetShowExp(ByVal strText,ByVal strField)
	strText=trim(strText)
    if strText="" then exit function
    strText = Replace(strText,"（","(")
    strText = Replace(strText,"）",")")
    strText = Replace(strText,"＋","+")
    strText = Replace(strText,"＊","*")
    strText = Replace(strText,"－","-")
    strText = Replace(strText,"＝","=")
     strText = Replace(strText,"""","")
    GetShowExp = AddShow(strText,strField)
End Function

function GetExpress1(ByVal strText,ByVal strField)
	strText=trim(strText)
    if strText="" then exit function
    strShowExpress = ""
    'strText = UCase(strText)    
    strText = Replace(strText,"（","(")
    strText = Replace(strText,"）",")")
    strText = Replace(strText,"＋","+")
    strText = Replace(strText,"＊","*")
    strText = Replace(strText,"－","-")
    strText = Replace(strText,"＝","=")
    strText = replace(strText,"""+""","%0x002B%")
    strText = replace(strText,"""-""","%0x002D%")
    strText = replace(strText,"""*""","%0x002A%")
    strText = replace(strText,"(","%0x0028%")
    'strText = replace(strText,")","%0x0029%")
    strText = AddField(strText,strField)    
    'strText = IssnCondition(strText,"I=")
    'strText = IssnCondition(strText,"N=")
    dim sField,sExpress,sMid,I,J,K,sNewExpress,sValue,sXX,sXY
    dim sNewField,bFound,sExtractValue,sBracket
    Dim sOldValue, sBlueValue
    dim sLeftValue,sRightValue
    
    sOldValue = "" : sBlueValue = ""
    I = 0
    sMid = SeprateString(strText,"=")
    do While sMid <> ""
    	if I=0 then
    		sField = sField & "\~" & sMid
    	else
    		if strText <> "" then
    			sField = sField & "\~" & Right(RTrim(sMid),1)
    			sExpress=sExpress & "\~" & Left(RTrim(sMid),len(RTrim(sMid))-1)
    		else
    			sExpress=sExpress & "\~" & sMid
    		end if
    	end if
    	I = I+1
    	sMid = SeprateString(strText,"=")
    Loop
    if sField <> "" then sField = Mid(sField,3)
    if sExpress <> "" then sExpress = Mid(sExpress,3)
    sMid = SeprateString(sField,"\~")
    sValue = SeprateString(sExpress,"\~")
    do While sMid <> ""
    	if Instr(sMid,"U")>0 then
	   	    '要求进行特殊处理，空格要处理成与的关系
	   	    sLeftValue = "" : sRightValue = ""
	   	    Do While (IsOperation(Left(sValue,1)) OR IsBracket(Left(sValue,1)) OR IsMyRelation(Left(sValue,1)))
	   	    	sLeftValue = sLeftValue & Left(sValue,1)
	   	    	sValue = Trim(Mid(sValue,2))
	   	    Loop
	   	    Do While (IsOperation(Right(sValue,1)) OR IsBracket(Right(sValue,1)) OR IsMyRelation(Right(sValue,1)))
	   	    	sRightValue = Right(sValue,1) & sRightValue
	   	    	sValue = Trim(Left(sValue,Len(sValue)-1))
	   	    Loop
	   	    sValue = sLeftValue & sValue & sRightValue
	   	    
	   	    '把空格处理成＊。因为中间可能有多个空格，所以不能用Replace函数
	   	    sRightValue=""
	   	    sLeftValue = SeprateString(sValue," ")
	   	    ncount=0
	   	    Do while (sLeftValue<>"") AND (ncount<=5)
	   	    	sRightValue = sRightValue & "*"  & Trim(sLeftValue)
	   	    	sValue = Trim(sValue)
	   	    	sLeftValue = SeprateString(sValue," ")
	   	    	ncount=ncount+1
	   	    loop
	   	    if sRightValue<>"" then sRightValue = Mid(sRightValue,2)
	   	    '处理在末尾或的特殊符号
	   	    if len(sRightValue)>1 then
	   	    	if left(sRightValue,1)="." then   sRightValue=mid(sRightValue,2)
	   	    	if right(sRightValue,1)="." then  sRightValue=mid(sRightValue,1,len(sRightValue)-1)
	   	    else
	   	    	if sRightValue="." then   sRightValue="%0x002E%"
	   	    end if
	   	    sRightValue = Replace(sRightValue,".","*")	'2003-07-30  LiuHui request
	   	    sRightValue = Replace(sRightValue,"-","%0x002D%")	'2003-08-07  LiuHui request
	   	    Do While Instr(sRightValue,"**")>0
	   	    	sRightValue=Replace(sRightValue,"**","*")
	   	    Loop
	'   	DO While Right(sRightValue,1)="*"
	'   		sRightValue = Left(sRightValue,len(sRightValue)-1)
	'   	Loop
				
	   	    sValue = sRightValue
	    	sNewExpress = sNewExpress & Replace(sMid,"U","任意字段") & "=" & sValue
	    else
	   	    sExtractValue = Trim(GetRigorExpress(sValue,False))
   	    
	   	    '要求进行特殊处理，空格要处理成与的关系
	   	    sLeftValue = "" : sRightValue = ""
	   	    Do While (IsOperation(Left(sExtractValue,1)) OR IsBracket(Left(sExtractValue,1)) OR IsMyRelation(Left(sExtractValue,1)))
	   	    	sLeftValue = sLeftValue & Left(sExtractValue,1)
	   	    	sExtractValue = Trim(Mid(sExtractValue,2))
	   	    Loop
	   	    Do While (IsOperation(Right(sExtractValue,1)) OR IsBracket(Right(sExtractValue,1)) OR IsMyRelation(Right(sExtractValue,1)))
	   	    	sRightValue = Right(sExtractValue,1) & sRightValue
	   	    	sExtractValue = Trim(Left(sExtractValue,Len(sExtractValue)-1))
	   	    Loop
	   	    sExtractValue = sLeftValue & sExtractValue & sRightValue
	   	    
	   	    '把空格处理成＊。因为中间可能有多个空格，所以不能用Replace函数
	   	    sRightValue=""
	   	    sLeftValue = SeprateString(sExtractValue," ")
	   	    Do while sLeftValue<>""
	   	    	sRightValue = sRightValue & "*" & Trim(sLeftValue)
	   	    	sExtractValue = Trim(sExtractValue)
	   	    	sLeftValue = SeprateString(sExtractValue," ")
	   	    loop
	   	    if sRightValue<>"" then sRightValue = Mid(sRightValue,2)
	   	    sExtractValue = sRightValue
	
	   	    '处理字段名。注意不能用 TranceField。因为sMid中可能有括号等符号
	   	    'if Instr(sMid,"I")>0 then
	   	    '	sMid = Replace(sMid,"I","ISSN")
	   	    '	sMid =Replace(sMid,"-","*")
	   	    	sExtractValue = Replace(sExtractValue, "Y", "%0x002D%")   	    
	   	    'elseif Instr(sMid,"A")>0 then
	   	    '	sMid = Replace(sMid,"A","Author")
	   	    	if len(sExtractValue)>1 then
	   	    		if left(sExtractValue,1)="," then   sExtractValue=mid(sExtractValue,2)
	   	    		if right(sExtractValue,1)="," then  sExtractValue=mid(sExtractValue,1,len(sExtractValue)-1)
	   	    		if left(sExtractValue,1)=";" then   sExtractValue=mid(sExtractValue,2)
	   	    		if right(sExtractValue,1)=";" then  sExtractValue=mid(sExtractValue,1,len(sExtractValue)-1)   	    	
	   	    	else
	   	    		if sExtractValue="," then sExtractValue="%0x002D%"
	   	    		if sExtractValue=";" then sExtractValue="%0x003B%"
	   	    	end if
	   	    	sExtractValue = Replace(sExtractValue,",","*")
	   	    	sExtractValue = Replace(sExtractValue,";","*")
	   	    	
	   	    if len(sExtractValue)>1 then
	   	    	if left(sExtractValue,1)="." then   sExtractValue=mid(sExtractValue,2)
		   	    if right(sExtractValue,1)="." then  sExtractValue=mid(sExtractValue,1,len(sExtractValue)-1)   	    
	   	    else
	   	    	if sExtractValue="." then sExtractValue="%0x002E%"
	   	    end if
	   	    sExtractValue = Replace(sExtractValue,".","*")	'2003-07-30  LiuHui request
	   	    sExtractValue = Replace(sExtractValue,"-","%0x002D%")	'2003-08-07  LiuHui request
	   	    sExtractValue = Replace(sExtractValue,"_","%0x002D%")	'2003-08-07  LiuHui request
	   	    
	   	    Do While Instr(sExtractValue,"**")>0
	   	    	sExtractValue=Replace(sExtractValue,"**","*")
	   	    Loop
	 '  	DO While Right(sExtractValue,1)="*"
	 '  		sExtractValue = Left(sExtractValue,len(sExtractValue)-1)
	 '  	Loop
	   	    if Instr(sMid,"C")>0 then
	   	    	sMid = Replace(sMid,"C","ComName")
	   	    	if sExtractValue <> "" Then sNewExpress = sNewExpress & sMid & "=" & sExtractValue
	   	    elseif Instr(sMid,"G")>0 then
	   	    	sMid = Replace(sMid,"G","Country")
	   	    	if sExtractValue <> "" Then sNewExpress = sNewExpress & sMid & "=" & sExtractValue
	   	    elseif Instr(sMid,"F")>0 then
	   	    	sMid = Replace(sMid,"F","strFileType")
	   	    	if sExtractValue <> "" Then sNewExpress = sNewExpress & sMid & "=" & sExtractValue
	   	    elseif Instr(sMid,"P")>0 then
	   	    	If sExtractValue <> "" Then sNewExpress = sNewExpress & "ProductName=(" & replace(sExtractValue," ","*") & ")+ProductName_C=(" & replace(sExtractValue," ","*") & ")" 
	   	    elseif Instr(sMid,"Q")>0 then
	   	    	If sExtractValue <> "" Then sNewExpress = sNewExpress & "strProName=(" & replace(sExtractValue," ","*") & ")+strProName_C=(" & replace(sExtractValue," ","*") & ")" 
	   	    elseif Instr(sMid,"R")>0 then
	   	    	sMid = Replace(sMid,"R","SunwayClass")
	   	    	if sExtractValue <> "" Then sNewExpress = sNewExpress & sMid & "=" & sExtractValue
	   	    elseif Instr(sMid,"S")>0 then
	   	    	sMid = Replace(sMid,"S","SunwayClassName")
	   	    	if sExtractValue <> "" Then sNewExpress = sNewExpress & sMid & "=" & sExtractValue
	   	    elseif Instr(sMid,"K")>0 then
	   	    	If sExtractValue <> "" Then sNewExpress = sNewExpress & "Keyword=(" & replace(sExtractValue," ","*") & ")+Keyword_C=(" & replace(sExtractValue," ","*") & ")" 
	   	    elseif Instr(sMid,"L")>0 then
	   	    	sMid = Replace(sMid,"L","strComName")
	   	    	if sExtractValue <> "" Then sNewExpress = sNewExpress & sMid & "=" & sExtractValue
	   	    elseif Instr(sMid,"M")>0 then
	   	    	If sExtractValue <> "" Then sNewExpress = sNewExpress & "Introduce=(" & replace(sExtractValue," ","*") & ")+Introduce_C=(" & replace(sExtractValue," ","*") & ")" 
	   	    elseif Instr(sMid,"N")>0 then
	   	    	If sExtractValue <> "" Then sNewExpress = sNewExpress & "strRemark=(" & replace(sExtractValue," ","*") & ")+strRemark_C=(" & replace(sExtractValue," ","*") & ")" 
	   	    else
	   	    	sMid = Replace(sMid,"U","任意字段")
	   	    	if sExtractValue <> "" Then sNewExpress = sNewExpress & sMid & "=" & sExtractValue
	   	    end if
	   	   	    
	   	    
	    	//sNewExpress = sNewExpress & sMid & "=" & sExtractValue	    	
    	end if
    	
    	If IsOperation(Right(sExtractValue, 1)) Then sOldValue = Right(sExtractValue, 1)
    	I = I+1
    	sMid = SeprateString(sField,"\~")
    	sValue = SeprateString(sExpress,"\~")
    loop
    'GetExpress1 = sNewExpress
    Dim strMid, strDeal
	Dim nTemp, nBegin, nEnd, strRes
	strRes = ""
	For nTemp = 1 To Len(sNewExpress)
	    strMid = Mid(sNewExpress, nTemp, 1)
	    If strMid = """" Then
	        If nBegin > 0 Then
	            nEnd = nTemp
	            
	            strDeal = Mid(sNewExpress, nBegin + 1, nEnd - nBegin - 1)
	            strDeal = Replace(strDeal, "+", "%0x002B%")
	            strDeal = Replace(strDeal, "-", "%0x002D%")
	            strDeal = Replace(strDeal, "*", "%0x002A%")
	            strDeal = Replace(strDeal, "(", "%0x0028%")
	            strDeal = Replace(strDeal, ")", "%0x0029%")
	            strDeal = Replace(strDeal, "{", "%0x007B%")
	            strDeal = Replace(strDeal, "}", "%0x007D%")
	            strDeal = Replace(strDeal, "=", "%0x003D%")
	            strRes = strRes & strDeal
	            
	            nBegin = 0
	            nEnd = 0
	        Else
	            nBegin = nTemp
	        End If
	    Else
	        If nBegin = 0 Then
	            strRes = strRes & strMid
	        End If
	    End If
	Next
	If nBegin > 0 And nEnd = 0 Then
	    strRes = strRes & Mid(sNewExpress, nBegin)
	End if	
	strRes = replace(strRes,"[[","[")
	strRes = replace(strRes,"]]","]")
    GetExpress1 = strRes   
end function

'取得年度条件
Function GetYear()
	if TRIM(document.all("BeginYear").value)="" AND TRIM(document.all("EndYear").value)="" then
		GetYear = ""
		exit function
	End if
	if Cint(document.all("BeginYear").value) > Cint(document.all("EndYear").value) then
		MsgBox "您输入的开始年大于了结束年!",vbExclamation,"提示信息"
		GetYear = "Err"
		exit function
	end if
	if Cint(document.all("BeginYear").value) = Cint(document.all("EndYear").value) then
		GetYear = "Year=" & document.all("BeginYear").value
		exit function
	End if
	if Cint(document.all("BeginYear").value) = 1995 AND Cint(document.all("EndYear").value)=2008 then
		GetYear = ""
		exit function
	end if
	if Cint(document.all("BeginYear").value) >1995 then		
 		for i= Cint(document.all("BeginYear").value) to Cint(document.all("EndYear").value)
 			GetYear = GetYear & "+Year=" & i
 		next
 		GetYear = "(" & Mid(GetYear,2) & ")"
	end if
	if Cint(document.all("BeginYear").value) <=1995 then		
 		for i= 1995 to Cint(document.all("EndYear").value)
 			GetYear = GetYear & "+Year=" & i
 		next
 		GetYear = "(" & Mid(GetYear,2) & ")"
	end if
End Function

'取得检索范围
Function GetRange()
	GetDB=""
End Function

function GetRel(byval strVV)
	if strVV="与" then
		GetRel="*"
	elseif strVV="或" then
		GetRel="+"
	else
		GetRel="-"
	end if
end function
function GetField(byval i)
	dim strField
	dim strKey
	strKey = document.all("select"&CStr(i)).value
	strField = strKey
	GetField = strField
end function 

sub DoSearch()
	dim strYear
	dim i,strExpress,strAllExpress,strField,strValue
	dim str1,strShowExpress,mstrShowExpress
	dim blnNullFound,bAll
	dim strSearch
	dim strShow
	dim bFlag
	dim strTS,strXKZY,strGB,strQY
	strXKZY=""
	strGB=""
	strQY=""
	
	for i=0 to 3
		strField = GetField(i)	
		strValue=trim(document.all("text"&CStr(i)).value)
		if strTS="" then
			strTS = strValue
		else
			strTS = strTS & " " & strValue
		end if
		strExpress=GetExpress1(strValue,GetField(i))	
		strShow = GetShowExp(strValue,GetField(i))
		if strExpress <> "" then
			if strAllExpress="" then
				strAllExpress=strExpress
			else
				'strAllExpress = "(" & strAllExpress & ")" & GetRel(document.all("Relation" & i).value) & "(" & strExpress & ")"
				strAllExpress =  strAllExpress &  GetRel(document.all("Relation" & i).value) &  strExpress
			end if
			if strShowExpress="" then
				strShowExpress = strShow
			else
				'strShowExpress = "(" & strShowExpress & ")" & GetRel(document.all("Relation" & i).value) & "(" & strShow & ")"
				strShowExpress =strShowExpress & GetRel(document.all("Relation" & i).value) & strShow
			end if
		end if		
	next
		
	strXKZY = ChkZY()
	strShowXKZY = ChkZYShow()
	if len(strXKZY)>0 then
		if len(strAllExpress)=0 then
			strAllExpress = "XueKeClass=(" & strXKZY & ")"
			strShowExpress = "学科=(" & strShowXKZY & ")"
		else
			strAllExpress = strAllExpress & "*XueKeClass=(" & strXKZY & ")"	
			strShowExpress = strShowExpress & "*学科=(" & strShowXKZY & ")"
		end if
	end if
	strGB = ChkGB()
	if len(strGB)>0 then
		if len(strAllExpress)=0 then
			strAllExpress = "Country=(" & strGB & ")"
			strShowExpress = "国家=(" & strGB & ")"
		else
			strAllExpress = strAllExpress & "*Country=(" & strGB & ")"	
			strShowExpress = strShowExpress & "*国家=(" & strGB & ")"
		end if
	end if
	strQY = ChkQY()
	strQYShow = ChkQYShow()
	if len(strQY)>0 then
		if len(strAllExpress)=0 then
			strAllExpress = "(" & strQY & ")"
			strShowExpress = "(" & strQYShow & ")"
		else
			strAllExpress = strAllExpress & "*(" & strQY & ")"	
			strShowExpress = strShowExpress & "*(" & strQYShow & ")"
		end if
	end if
	'alert(strAllExpress)
	'alert(strShowExpress)
	window.status="正在检索中..."
	frmSearch.Exp.value=strAllExpress
	frmSearch.Show.value=strShowExpress
	frmSearch.action="../bin/swgpd.dll?Search"
	frmSearch.target="_self"
	frmSearch.submit
End sub

