home *** CD-ROM | disk | FTP | other *** search
- Function GetPatternPart(ByRef p_strPattern, ByRef p_strPatternPart)
- Dim result As Integer
- result = -1
- If p_strPattern = "" Then
- result = 0
- Else
- Select Case Left(p_strPattern, 1)
- Case "x", "X"
- result = 1
- p_strPattern = Mid(p_strPattern, 2, Len(p_strPattern) - 1)
- Case "?"
- result = 2
- p_strPattern = Mid(p_strPattern, 2, Len(p_strPattern) - 1)
- Case "*"
- result = 3
- p_strPattern = Mid(p_strPattern, 2, Len(p_strPattern) - 1)
- Case "'", "#"
- result = 4
- p_strPatternPart = ""
- If Left(p_strPattern, 1) = "#" Then
- p_strPattern = Mid(p_strPattern, 2, Len(p_strPattern) - 1)
- If (p_strPattern <> "") And IsNumeric(Left(p_strPattern, 1)) Then
- Dim code As Integer
- code = CInt(Left(p_strPattern, 1))
- p_strPattern = Mid(p_strPattern, 2, Len(p_strPattern) - 1)
- If (p_strPattern <> "") And IsNumeric(Left(p_strPattern, 1)) Then
- code = code * 10 + CInt(Left(p_strPattern, 1))
- p_strPattern = Mid(p_strPattern, 2, Len(p_strPattern) - 1)
- If (p_strPattern <> "") And IsNumeric(Left(p_strPattern, 1)) Then
- code = code * 10 + CInt(Left(p_strPattern, 1))
- p_strPattern = Mid(p_strPattern, 2, Len(p_strPattern) - 1)
- End If
- End If
- If code > 255 Then
- result = -1
- Else
- p_strPatternPart = p_strPatternPart + Chr(code)
- End If
- Else
- result = -1
- End If
- Else
- p_strPattern = Mid(p_strPattern, 2, Len(p_strPattern) - 1)
- Dim bStringDone As Boolean
- bStringDone = FALSE
- While (p_strPattern <> "") And Not bStringDone
- If Left(p_strPattern, 1) = "'" Then
- bStringDone = TRUE
- Else
- p_strPatternPart = p_strPatternPart + Left(p_strPattern, 1)
- End If
- p_strPattern = Mid(p_strPattern, 2, Len(p_strPattern) - 1)
- Wend
- If (p_strPattern = "") And Not bStringDone Then
- result = -1
- End If
- End If
- If p_strPatternPart = "" Then
- result = -1
- End if
- End Select
- End If
- GetPatternPart = result
- End Function
-
- Function MatchString(p_strPattern, p_strBanner)
- Dim result As Boolean
- result = TRUE
- Dim strPattern As String
- strPattern = p_strPattern
- Dim strBanner As String
- strBanner = p_strBanner
- If strPattern <> "" Then
- Dim bStar As Boolean
- bStar = FALSE
- Dim bEqual As Boolean
- If Left(strPattern, 1) = "=" Then
- bEqual = TRUE
- strPattern = Mid(strPattern, 2, Len(strPattern) - 1)
- Else
- bEqual = FALSE
- bStar = TRUE
- End If
- Do While strBanner <> ""
- Dim patternType As Integer
- Dim strPatternPart As String
- patternType = GetPatternPart(strPattern, strPatternPart)
- Select Case patternType
- Case 1
- If bStar Then
- bStar = FALSE
- While (strBanner <> "") And Not IsNumeric(Left(strBanner, 1))
- strBanner = Mid(strBanner, 2, Len(strBanner) - 1)
- Wend
- If strBanner = "" Then
- result = FALSE
- Exit Do
- End If
- Else
- If Not IsNumeric(Left(strBanner, 1)) Then
- result = FALSE
- Exit Do
- End If
- End If
- If strBanner <> "" Then
- strBanner = Mid(strBanner, 2, Len(strBanner) - 1)
- End If
- Case 2
- strBanner = Mid(strBanner, 2, Len(strBanner) - 1)
- Case 3
- bStar = TRUE
- Case 4
- Dim nPos As Integer
- nPos = InStr(1, strBanner, strPatternPart)
- If nPos <> 0 Then
- If bStar Then
- bStar = FALSE
- strBanner = Right(strBanner, Len(strBanner) - (nPos + Len(strPatternPart) - 1))
- Else
- If nPos <> 1 Then
- result = FALSE
- Exit Do
- Else
- strBanner = Right(strBanner, Len(strBanner) - (Len(strPatternPart) - 1))
- End If
- End If
- Else
- result = FALSE
- Exit Do
- End If
- Case 0
- If bEqual And Not bStar Then
- result = FALSE
- End If
- Exit Do
- Case -1
- result = FALSE
- Exit Do
- End Select
- Loop
- If (strBanner = "") And (strPattern <> "") And (strPattern <> "*") Then
- result = FALSE
- End If
- End If
- MatchString = result
- End Function
-