TIP: Click on subject to list as thread! ANSI
echo: visual_basic
to: All
from: Gigamuxer donotspanme{at}sp
date: 2005-02-05 14:35:00
subject: Re: BInary file header parser.

Mike Williams wrote:
> "GigaMuxer"  wrote in message
> news:ldCdndkkKtFciZnfRVn-rA{at}comcast.com...
>
>
>>"Using CopyMemory to push the bytes into UDT" This is what
>>I am looking for.  Do you have a similar example(s)?
>
>
> I've never been "into" all this professional database stuff
and so I don't
> quite understand what you mean by all these "packets" and
"payloads"
> buzzwords, but if your data file is arranged in the way I think it might be
> then you don't need to use CopyMemory and you can instead load the data
> straight into an array.
>
> You say that your file contains a number of packets and that each packet
> contains 32 bytes of data consisting of 3 header bytes and 29 data bytes. Is
> that correct? In that case, your file will always be an exact whole multiple
> of 32 bytes long. Is that also true? If the answer to both of those
> questions is "yes" then you can read and analyze the data
very easily. The
> following example doesn't contain any error checking code or anything, and
> is just a simple "starting point" for you, but it is capable
of very rapidly
> reading the entire 5 MB file into memory in such a way that you can then
> "get at" the data of any packet you desire without any
further disk access.
> Paste the following code into a VB Form containing one command button and
> one list box . . .
>
> Mike
>
> Option Explicit
> Private Type Packet
>   sync As Byte
>   identifier As Byte
>   type As Byte
>   data(0 To 28) As Byte
> End Type
>
> Private Sub Command1_Click()
> Dim n As Long, p As Long
> Open "c:\mike.dta" For Binary As 1
> ReDim blocks(0 To LOF(1) / 32 - 1) As Packet
> Get 1, 1, blocks()
> Close 1
> ' The number of the first block is 0 and the number
> ' of the last block is UBound(blocks)
> '
> ' check correct operation by displaying the
> ' contents of the first block (block 0)
> n = 0
> List1.AddItem blocks(n).sync
> List1.AddItem blocks(n).identifier
> List1.AddItem blocks(n).type
> For p = 0 To 28
>   List1.AddItem blocks(n).data(p)
> Next p
> End Sub
>
>
>
>
>
>
You are correct in your assumptions above.  I'll give it a try and post
my results.  You guys are very helpfull.

Regards,
LRR


--- UseNet To RIME Gateway {at} 2/5/05 2:26:00 PM ---
* Origin: MoonDog BBS, Brooklyn,NY, 718 692-2498, 1:278/230 (1:278/230)
SEEN-BY: 633/267 270 5030/786
@PATH: 278/230 10/345 106/1 2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.