G
Guest
Hi all,
I'm here to humbly request some "gimme" help from the group. I discovered
the infinite wonders of VS.NET 2005 and ASP.NET 2.0 at Tech Ed a couple of
weeks ago, and since returning to work I haven't looked back. Unfortunately
I still have some critical functions that I originally created as vbscript
functions. I need these functions to do my work. Before I can transition
entirely to C#-based ASP.NET sites, I need these functions to be translated
to C# syntax.
I've managed most on my own. The most difficult to translate is a function I
made to prepare a text string so that it is in the proper format demanded by
SQL Server's awesome Full Text Search capability.
Ideally, someone knows of an analogous function that's already been hacked
up in C#. I'd imagine this particular wheel has been reinvented a few
billion times.
Barring that, I'm hoping some of the sharper Csharpers will hold my hand and
help me translate the function to C#. It's straight string manipulation
stuff, and appears below. Thanks in advance for any help you can offer.
Ken Fine
University of Washington
Function CreateSQLContainsString(s, requireAllWords)
dim i, start, result, sLen, conjunction, token, fSeparator
result = ""
start = 1
sLen = Len(s)
fSeparator = False
If requireAllWords Then
conjunction = " AND"
Else
conjunction = " OR"
End If
For i = 1 to sLen
ch = Mid(s, i, 1)
If (ch="""") Then
i = i + 1
While (i < sLen AND Mid(s,i,1) <> """")
i = i + 1
Wend
End If
If (ch=" " or i = sLen) Then
token = Trim(Mid(s, start, i-start+1))
utoken = UCase(token)
If start = 1 Then
result = token
ElseIf (utoken = "AND" or utoken="OR" or utoken="NEAR") Then
result = result + " " + utoken
fSeparator = TRUE
Else
If fSeparator = FALSE Then
result = result + conjunction
End If
result = result + " " + token
fSeparator = FALSE
End If
start = i + 1
End If
Next
CreateSQLContainsString = result
End Function
I'm here to humbly request some "gimme" help from the group. I discovered
the infinite wonders of VS.NET 2005 and ASP.NET 2.0 at Tech Ed a couple of
weeks ago, and since returning to work I haven't looked back. Unfortunately
I still have some critical functions that I originally created as vbscript
functions. I need these functions to do my work. Before I can transition
entirely to C#-based ASP.NET sites, I need these functions to be translated
to C# syntax.
I've managed most on my own. The most difficult to translate is a function I
made to prepare a text string so that it is in the proper format demanded by
SQL Server's awesome Full Text Search capability.
Ideally, someone knows of an analogous function that's already been hacked
up in C#. I'd imagine this particular wheel has been reinvented a few
billion times.
Barring that, I'm hoping some of the sharper Csharpers will hold my hand and
help me translate the function to C#. It's straight string manipulation
stuff, and appears below. Thanks in advance for any help you can offer.
Ken Fine
University of Washington
Function CreateSQLContainsString(s, requireAllWords)
dim i, start, result, sLen, conjunction, token, fSeparator
result = ""
start = 1
sLen = Len(s)
fSeparator = False
If requireAllWords Then
conjunction = " AND"
Else
conjunction = " OR"
End If
For i = 1 to sLen
ch = Mid(s, i, 1)
If (ch="""") Then
i = i + 1
While (i < sLen AND Mid(s,i,1) <> """")
i = i + 1
Wend
End If
If (ch=" " or i = sLen) Then
token = Trim(Mid(s, start, i-start+1))
utoken = UCase(token)
If start = 1 Then
result = token
ElseIf (utoken = "AND" or utoken="OR" or utoken="NEAR") Then
result = result + " " + utoken
fSeparator = TRUE
Else
If fSeparator = FALSE Then
result = result + conjunction
End If
result = result + " " + token
fSeparator = FALSE
End If
start = i + 1
End If
Next
CreateSQLContainsString = result
End Function