writing uint16's to a binary file

Bob Arning arning at charm.net
Tue Mar 12 19:10:51 UTC 2002


On Tue, 12 Mar 2002 11:49:05 -0700 Ken Brown <ken.brown at zedisolutions.com> wrote:
>When I index into the ByteArray at 2, I'm having trouble understanding what
>it means exactly.
>Any help appreciated. 

Ken,

I'm not sure how many of the examples you gave are causing you problems, but as far as what "shortAt: index put: value bigEndian: aBool" means, try this:

1 to: 5 do: [ :j |
	b _ ByteArray new: 6.
	b shortAt: j put: 258 bigEndian: false.
	Transcript show: j printString,' --> ',b printString; cr.
].

and you will get this:

1 --> a ByteArray(2 1 0 0 0 0)
2 --> a ByteArray(0 2 1 0 0 0)
3 --> a ByteArray(0 0 2 1 0 0)
4 --> a ByteArray(0 0 0 2 1 0)
5 --> a ByteArray(0 0 0 0 2 1)

I chose to store 258 to make it clear which two bytes of the ByteArray got which bytes of the short integer.

Cheers,
Bob



More information about the Squeak-dev mailing list