On Feb 16, 2007, at 3:18 PM, Charles Yeomans wrote:

InStrB returns 0 if no match is found, so this loop will never terminate. Instead --
        

Dim f As FolderItem = GetFolderItem(filePath, FolderItem.PathTypeShell)
        // check for bad f instance
        Dim fs As TextInputStream = f.OpenAsTextFile
        // check for nil fs
        theFileString = fs.ReadAll
        dim matchStringLength as Integer = LenB(matchString)
        Dim keyOffset As Integer = 1
        Do
                keyOffset = InStrB(keyOffset, theFileString, matchString )
                if keyOffset > 0 then
                  // Process located data
                  keyOffset = keyOffset + matchStringLength
                else
                  exit
                end if
        Loop

Tim,

Since encodings shouldn't matter in this case since it's binary data, I would use a binary stream and be sure to use the "B" version of InStr and related calls as Charles used here. That should be faster.

My other thought Charles also accounted for with this code:
keyOffset = keyOffset + matchStringLength.


Kevin
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to