writing uint16's to a binary file

Ken G. Brown kbrown at tnc.ab.ca
Mon Mar 11 18:57:44 UTC 2002


Writing the numbers either endian is fine, with a slight preference for
little endian. My intent for the uint16 was to get each element of the
collection via ReadStream on it, as 16 bits for each number. I would ensure
the size is less than 65535 when I fill the collection. I'm certainly open
to finding the best way to accomplish this.
Thx
Ken

> -----Original Message-----
> From: squeak-dev-admin at lists.squeakfoundation.org
> [mailto:squeak-dev-admin at lists.squeakfoundation.org]On Behalf Of Ned
> Konz
> Sent: March 11, 2002 11:28 AM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: Re: writing uint16's to a binary file
>
>
> On Monday 11 March 2002 10:04 am, Ken G. Brown wrote:
> > I'm needing to write a bunch of lines of uint16's to a
> binary file. So far
> > I have a variation of the following but it gives a message
> not understood,
> > adaptToNumber:andSend:.
> >
> > test _ #(1 2 3 4 5 6 7 8).
> > rStr _ ReadStream on: test.
> > outfile _ fileStream _ (FileStream newFileNamed: 'outfile') binary.
> > outfile nextPutAll: (rStr do: [ :ii | rStr uint16]).
> > outfile close.
> >
> > I'm stuck at this point. Any tips would be appreciated.
>
> I'm not sure why you're using the "uint16" message, which
> reads from a binary
> stream (which test isn't).
>
> Anyway, do you need to write these numbers big-endian or
> little-endian?
>
> Look at StandardFileStream>>nextWordsPutAll: for one possibility...
>
> --
> Ned Konz
> currently: Stanwood, WA
> email:     ned at bike-nomad.com
> homepage:  http://bike-nomad.com




More information about the Squeak-dev mailing list