[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Counting records in a binary file
- From: "Javier Guerra" <javier@...>
- Date: Mon, 15 Sep 2008 11:22:25 -0500
On Mon, Sep 15, 2008 at 11:13 AM, Jeff Wise <jwise@sealyrealty.com> wrote:
>> - convert bytes 2,3 to a number 'N'
>> - skip N bytes
>
> I'm sorry, but I have no clue how to convert bytes 2,3 to a number, nor how to skip N bytes. Can you elaborate, perhaps a code snippet?
(really untested):
local count = 0
local offset = 0
while offset < strlength do
assert (string.byte(s,offset+1) == 0x5A, 'no header')
count = count+1
local b2,b3 = string.byte (s, offset+2, offset+3)
offset = offset + b2*256+b3
end
--
Javier