hi, i've looked all over the web for help, i've tried converting myself 10 times or more, and i have no success, please is there anyone that can help me convert these functions from VB to Delphi 7....
note: datWords is vb 'Data' component, also this is none strict code, but it works how i need, so please...i would be very greatful for any help.
Code:
Private Function ProcessWords(Data) As String
Dim words(20) As String
Computer = ""
Human = LCase(Trim(Data))
Human = "^" & Human & "^"
Human = " " & Human & " "
Start = 1
cword = 1
For a = 1 To Len(Human)
If Mid(Human, a, 1) = " " And a > 1 Then
words(cword) = Mid(Human, Start + 1, a - Start)
If Len(words(cword)) > Len(maxword) Then maxword = Trim(words(cword))
Start = a
cword = cword + 1
End If
Next a
rf = "'adkevriy'"
For a = 1 To cword - 1
If Trim(words(a)) <> "" Then
datWords.Recordset.AddNew
middle = Trim(words(a))
rf = rf & ",'" & middle & "'"
If a > 1 Then Previous = Trim(words(a - 1))
If a < cword Then nextT = Trim(words(a + 1))
datWords.Recordset.FindFirst ("middle = '" & Trim(words(a)) & "' and previous = '" & Trim(words(a - 1)) & "' and next = '" & Trim(words(a + 1)) & "'")
If datWords.Recordset.NoMatch = True Then
datWords.Recordset.AddNew
datWords.Recordset.Fields(0) = middle
datWords.Recordset.Fields(1) = Previous
datWords.Recordset.Fields(2) = nextT
datWords.Recordset.Update
End If
End If
Next a
Human = ""
Set dbs = OpenDatabase(App.Path & "\nlp.mdb")
Set tdf = dbs.OpenRecordset("select middle,count(middle) from words where middle in (" & rf & ") group by middle order by count(middle)")
maxword = tdf.Fields(0)
Computer = maxword
wrd = choose(maxword, False)
Do While wrd <> ""
Computer = wrd & " " & Computer
wrd = choose(wrd, False)
Loop
wrd = choose(maxword, True)
Do While wrd <> ""
Computer = Computer & " " & wrd
wrd = choose(wrd, True)
Loop
Computer = Mid(Computer, 2, Len(Computer) - 2)
comp = Computer
Computer = ""
picprog.ScaleWidth = Len(comp)
For c = 1 To Len(comp)
Computer = Computer & Mid(comp, c, 1)
For a = 1 To Int(50000 * Rnd) + 5000
stuff = 5 * 5 * 5 * 5 * 5 * 5 * 2
Next a
Computer.Refresh
pbsp.Width = c
picprog.Refresh
Next c
ProcessWords = Computer
End Function
Public Function choose(word, forward As Boolean)
Set dbs = OpenDatabase(App.Path & "\nlp.mdb")
Set tdf = dbs.OpenRecordset("select * from words where middle = '" & word & "'")
rf = "'vkuseyvgwzelkbzwle'"
Do Until tdf.EOF
chkstr = IIf(forward = True, tdf!Next, tdf!Previous)
If InStr(1, Computer, chkstr) = 0 Or Len(rf) < 22 Then
rf = rf & ",'" & IIf(forward = True, tdf!Next, tdf!Previous) & "'"
End If
tdf.MoveNext
Loop
Set rare = dbs.OpenRecordset("select middle,count(middle) from words where middle in (" & rf & ") and " & _
IIf(forward = True, "previous = '" & word & "'", "next = '" & word & "'") & " group by middle order by count(middle)")
If rare.EOF = True Then
choose = ""
Else
Do Until rare.EOF
If Int((2 * Rnd) + 1) = 1 Then
choose = rare!middle
Exit Function
Else
rare.MoveNext
End If
Loop
rare.MoveFirst
choose = rare!middle
End If
End Function
-Seph
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).