nstrg
Jul 12th, 2000, 12:31 PM
What i'm trying to do is make a program somewhat simaliar to Napster. Everything works great so far, execpt that when 2 users try to search for a file at the sametime.. It stops sending the information to the first user and starts on the second, then when the second user has received all the messages, it starts back up on the first. My question is, is there anyway to get it to do both searchs at the sametime?
here is how i do the search:
****************
Public Function SearchFolder(folderpath As String, SearchSTR As String, num As Integer)
Dim thisFolder As Folder
Dim sFolder As Folders
Dim AllFiles As Files
Dim fileItem As File, folderitem As Folder
Dim tStream As TextStream
Dim line As String
Dim userid As String
Dim fName As String
Dim filedata As String
Dim t As Integer
Dim str11 As String
Dim str12 As String
Set thisFolder = Fsys.GetFolder(folderpath)
Set sFolder = thisFolder.SubFolders
Set AllFiles = thisFolder.Files
For Each folderitem In sFolder
DoEvents
SearchFolder App.Path & "\data\files\", SearchSTR, num
Next
For Each fileItem In AllFiles
DoEvents
Set tStream = Fsys.OpenTextFile(fileItem.Path, ForReading, False)
line = tStream.ReadLine
userid = TrimNull(line)
Do Until tStream.AtEndOfStream
DoEvents
line = tStream.ReadLine
If InStr(1, line, SearchSTR, vbTextCompare) Then
Sleep 140
t = InStr(1, line, "::")
If t Then
str11 = Left(line, t - 1)
str12 = Mid(line, t + 2, Len(line) - t)
End If
Sleep 110
fName = GetFileName(str11)
Call Sendout("[SRE]" & LCase(userid) & "::" & fName & "!L" & str12, num)
End If
Loop
Next
End Function
****************
Thanks -
Nate
here is how i do the search:
****************
Public Function SearchFolder(folderpath As String, SearchSTR As String, num As Integer)
Dim thisFolder As Folder
Dim sFolder As Folders
Dim AllFiles As Files
Dim fileItem As File, folderitem As Folder
Dim tStream As TextStream
Dim line As String
Dim userid As String
Dim fName As String
Dim filedata As String
Dim t As Integer
Dim str11 As String
Dim str12 As String
Set thisFolder = Fsys.GetFolder(folderpath)
Set sFolder = thisFolder.SubFolders
Set AllFiles = thisFolder.Files
For Each folderitem In sFolder
DoEvents
SearchFolder App.Path & "\data\files\", SearchSTR, num
Next
For Each fileItem In AllFiles
DoEvents
Set tStream = Fsys.OpenTextFile(fileItem.Path, ForReading, False)
line = tStream.ReadLine
userid = TrimNull(line)
Do Until tStream.AtEndOfStream
DoEvents
line = tStream.ReadLine
If InStr(1, line, SearchSTR, vbTextCompare) Then
Sleep 140
t = InStr(1, line, "::")
If t Then
str11 = Left(line, t - 1)
str12 = Mid(line, t + 2, Len(line) - t)
End If
Sleep 110
fName = GetFileName(str11)
Call Sendout("[SRE]" & LCase(userid) & "::" & fName & "!L" & str12, num)
End If
Loop
Next
End Function
****************
Thanks -
Nate