[REBOL] Working with binary data Re:
From: jsc::dataheaven::de at: 27-Sep-2000 3:33
On Wed, 27 Sep 2000, you wrote:
> If I read in a binary file I get this for example:
>
> variable: #{
> 524946462400000043444441666D742018000000010001005C774C0100000000
> B253000000020000332D0400
> }
>
> How do I navigate this to get to specific values and extract them and store
> them in variables?
To move forward in the binary block use skip to walk over the bytes.
To cut out a part of the binary-block use copy/part
e.g choose 4 bytes from byte position 3 (counted from 1 as it is common in
REBOL) in above block:
result: copy/part skip variable 2 4
== #{46462400}
If you want you can write a funciton to make it easier e.g:
cut: func [seq pos len] [
copy/part skip seq (pos - 1) len
]
So you can write the above example as:
cut variable 3 4
Regards
Jochen