lua-users home
lua-l archive

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


➢ ignore it, and don't waste time trying to use it

I must count the records. Each record begins with ‘5A’. After this ‘5A’ is a 2 byte length but it does not account for the ‘5A’. Unfortunately “gsub” will not count the records because there are ‘5A’ embedded.  Here is an example of the form '5A', nnnn, data bytes.

0000 "5A"  "0010” “606162636465666768696A6B6C”
0010 "6D" "5A" "0010" "707172737475767778797A7B"
0020 "7C7D" "5A" "0010" "808182838485865A88898A"
0030 "8B" ...

Hopefully there are 16 bytes in hex on each line. There are three records. Each of these rcords begin with '5A'. The last record (whose 16 bytes of data are incomplete) contains a data byte of '5A'. the length field does not accommodate the '5A' byte.

If I use GSUB, I count 4 records when there are really only three. To count this mess, I must use this 'nnnn' field after the '5A' signature byte. This is very straight-forward in assembler. How's it done in Lua? In the real world, the lengths vary and some of the long records (8200 bytes) contain several '5A' data bytes.