Does anyone have a code to provide VBScript with this same functionality
(and would be willing to provide me a copy)
It would be greatly appreciated.
Salty.
Ps. It's been one of "those" days so if I'm completely of track here and
VBScript does support the Like function feel free to vent some of your anger
on me. :)
Nathan Ernst
>.
>
Peter
"Salty" <salt...@newmail.net> wrote in message
news:OaDhKBaIBHA.1948@tkmsftngp03...
"Salty" <salt...@newmail.net> wrote in message
news:OaDhKBaIBHA.1948@tkmsftngp03...
On Fri, 10 Aug 2001 23:27:53 +1000, "Salty" <salt...@newmail.net>
wrote:
MsgBox IsLike("config.sys", "c*.*") 'returns true
Function IsLike(strText, match)
Dim i, str, spec, temp, token, nPos
' Turn strings to lower case
str = LCase(strText)
spec = LCase(match)
' Split the various components of the match string
aInput = split(spec, "*") ' "c*.*m" becomes Array("c", ".", "m")
' Walk the array of specification sub-components
i = 0
For Each token In aInput
' The first token plays an important role: the file name must begin
' with a substring identical to the token.
If i = 0 Then
temp = Left(str, Len(token))
' Don't match...
If temp <> token Then
IsLike = False
Exit Function
End If
' Removes the leading substring before next step
str = Right(str, Len(str) - Len(token))
Else
temp = str
' For each asterisk we come accross, we chack that what remains of
' the filename contains the next token of the match string.
nPos = Instr(1, temp, token)
' Don't match...
If nPos = 0 Then
IsLike = False
Exit Function
End If
' Removes the leading substring before next step
str = Right(str, Len(str) - nPos + 1)
End If
i = i + 1
Next
IsLike = True
End Function
"Salty" <salt...@newmail.net> wrote in message
news:OaDhKBaIBHA.1948@tkmsftngp03...
Torgeir