Andre <
geom...@gmail.com> wrote:
> I mean that How to export maximal 1024 bytes every line. Actually, I just
> need split the hex words every 1024 hex characters in every line.
It may be easier to tell [read $in] to only read 512 bytes, that will
then turn into 1024 hexdigits.
But you will need to put some of the commands into a loop.
Also, I'd suggest you open the file with mode "rb" to make sure tcl
doesn't translate the bytes in some way, e.g. turning a \r or \r\n
into a single \n .
> I was tried to export the hex string like puts $out $hex but this
> script just one line and make my text editor very very low and crast.
Tcl doesn't have any built-in function to just split a string every <n>
chars. I missed such, too, a couple of times, and fell back to rather
ugly workarounds, like [regexp -all -inline -- ".{0,1024}" $hex]
but that doesn't "feel" right to me.
In your case, reading just 512-byte chunks from the file in a loop
and translating each as you did, is preferrable over creating a string
double as large as the original file and then splitting it up in memory.