writing uint16's to a binary file

Ned Konz ned at bike-nomad.com
Mon Mar 11 18:27:32 UTC 2002


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