lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Try	local hex5A = string.char(0x5A)
Thanks. That solves part 1.

  _, count5A = string.gsub(bytes, hex5A, hex5A)

The larger problem is that the gsub is counting the valid "begin data
record" fields and the invalid bytes which are simply data. Since there are
no data types in Lua, I can't figure out how to index to the next record.

Again, the data looks like '5A', nnnn, other data
Where the nnnn is a two byte signed integer (and hi-order byte, low-order
byte, not Intel format). For example, many length fields are X'2008' meaning
8200 bytes. The objective is to count these records. This is complicated by
the fact that the "other data" may contain '5A' bytes.

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Luiz Henrique de
Figueiredo
Sent: Monday, September 15, 2008 9:03 AM
To: Lua list
Subject: Re: Reading binary files

> Sorry, the quotes were a typo. I did use "local hex5A = 0x5A".

Try	local hex5A = string.char(0x5A)

No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/14/2008
7:16 AM