Home > Language Reference > Classes > StreamMemory
FindByte Function
Finds the first occurence of a byte value in the data stream.
Syntax
Public Function FindByte(ByVal lStart As Long, ByVal bToFind As Byte) As Long
| Parameter | Description |
| lStart | Zero based index of the starting position of the search. |
| bToFind | Byte value to search for. |
Remarks
The FindByte function searches for the first occurence of the specified byte value in the data stream. The lStart parameter specifies the starting position for the search. The bToFind parameter specifies the value to search for.
If the search is successfull, the returned value is the zero based index of the first occurence found. If the specified value could not be found, or if the lStart parameter was greater than or equal to the size of the data stream, the value returned is -1.
This function is typically used to tokenize the data stream. The following example shows how to split data read from a text file into successive lines separated by a LF character:
Private Sub Tokenize(ByRef sData As StreamMemory)
Dim s as String
Dim i as Long, j as Long
Do Until j>=sData.Size
j=sData.FindByte(i,Asc("\n"))
If j<0 Then j=sData.Size
sData.Seek i
sData.Read s, j-i
i=j+1
MsgBox TrimCrlf(s)
Loop
End Sub
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | N/A |