S
Saga
Hello all, I have the code listed below. This *was* working. The binary
file has this structure:
2 bytes marker bytes
2 bytes flags
4 bytes 32 bit time stamp
2 bytes
x bytes null terminated text string
x bytes The Data
The text string is optional, so it may be 0 bytes. The fourth header
byte tells me this. I tested it thoroughly, but now that I have revisted
this process the fileget() is reading all zeroes for the marker bytes and
flags. I opened the file in DEBUG and verified that the expected data
was there. Any suggestions or ideas on alternate methods are welcomed.
Thank you, Saga
Dim TheBytes() As Byte
Dim strName As String = ""
Dim bytHeader(3) As Byte
Dim bytByte As Byte
Dim lngTimeStamp As Integer
Dim bytExtra(1) As Byte
Dim intFH As Integer
intFH = FreeFile()
FileOpen(intFH, strDataFile, OpenMode.Binary)
FileGet(intFH, (bytHeader))
'Check for valid marker bytes
If bytHeader(0) = 225 And bytHeader(1) = 179 Then
FileGet(intFH, lngTimeStamp)
'2 more bytes.
FileGet(intFH, (bytExtra))
If (bytHeader(3) And 16) = 16 Then
'Get the name.
Do
FileGet(intFH, bytByte)
If bytByte > 0 Then
strName = strName & Chr(bytByte)
End If
Loop Until bytByte = 0
End If
ReDim TheBytes(CInt(LOF(intFH) - 1))
FileGet(intFH, (TheBytes))
file has this structure:
2 bytes marker bytes
2 bytes flags
4 bytes 32 bit time stamp
2 bytes
x bytes null terminated text string
x bytes The Data
The text string is optional, so it may be 0 bytes. The fourth header
byte tells me this. I tested it thoroughly, but now that I have revisted
this process the fileget() is reading all zeroes for the marker bytes and
flags. I opened the file in DEBUG and verified that the expected data
was there. Any suggestions or ideas on alternate methods are welcomed.
Thank you, Saga
Dim TheBytes() As Byte
Dim strName As String = ""
Dim bytHeader(3) As Byte
Dim bytByte As Byte
Dim lngTimeStamp As Integer
Dim bytExtra(1) As Byte
Dim intFH As Integer
intFH = FreeFile()
FileOpen(intFH, strDataFile, OpenMode.Binary)
FileGet(intFH, (bytHeader))
'Check for valid marker bytes
If bytHeader(0) = 225 And bytHeader(1) = 179 Then
FileGet(intFH, lngTimeStamp)
'2 more bytes.
FileGet(intFH, (bytExtra))
If (bytHeader(3) And 16) = 16 Then
'Get the name.
Do
FileGet(intFH, bytByte)
If bytByte > 0 Then
strName = strName & Chr(bytByte)
End If
Loop Until bytByte = 0
End If
ReDim TheBytes(CInt(LOF(intFH) - 1))
FileGet(intFH, (TheBytes))