Re: Parsing large binary data without huge binary scan command
- From: "tom.rmadilo" <tom.rmadilo@xxxxxxxxx>
- Date: Mon, 28 Jul 2008 22:01:20 -0700 (PDT)
On Jul 28, 4:11 pm, "b...@xxxxxxxx" <ben.carb...@xxxxxxxxx> wrote:
For the format string, you can use [string repeat] to shorten it:
I think that will do the trick to make it readable.
One more idea, store the var name and length as a list then work over
the string
Example:
set bytes \x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x40\x41\x42
set var_len_list {
var1 1
var2 2
var3 3
var4 2
}
set index 0
foreach {varname len} $var_len_list {
binary scan [string range $bytes $index [expr [incr index $len]
-1]] H* $varname
puts "$varname = [set $varname] len = $len"
}
Output is:
var1 = 30 len = 1
var2 = 3132 len = 2
var3 = 333435 len = 3
var4 = 3637 len = 2
.
- References:
- Parsing large binary data without huge binary scan command
- From: ben@xxxxxxxx
- Re: Parsing large binary data without huge binary scan command
- From: Neil Madden
- Re: Parsing large binary data without huge binary scan command
- From: ben@xxxxxxxx
- Parsing large binary data without huge binary scan command
- Prev by Date: Re: Parsing large binary data without huge binary scan command
- Next by Date: Software Package Free! ... about our Free Software
- Previous by thread: Re: Parsing large binary data without huge binary scan command
- Next by thread: Re: Parsing large binary data without huge binary scan command
- Index(es):
Relevant Pages
|