Stream Question

Luciano Notarfrancesco core.lists.squeak at core-sdi.com
Tue Sep 18 10:43:30 UTC 2001


"Ken G. Brown" wrote:
> 
> Can anyone give some insight into why these snippets do not successfully
> read anything with the 'next' message?
> 
> strm _ ReadWriteStream on: (String new: 10000).
> strm nextPutAll: 'aaaaaaaaa'.
> get _ strm next. "gets nil"
> 
> strm _ ReadWriteStream on: (Array new: 10000).
> strm nextPutAll: 'aaaaaaaaa'.
> get _ strm next. "gets nil"
> 

This happens because the stream is positioned at the end of what you
wrote on it. If you reset the stream (set the position back to 0) before
reading it will work.

strm _ ReadWriteStream on: (String new: 10000).
strm nextPutAll: 'aaaaaaaaa'.

strm atEnd. "<alt-p> will be true"

strm position. "<alt-p> will be 9"

strm reset.
strm position. "<alt-p> now will be 0"

get _ strm next. "gets $a"

Work for peace,
Luciano.-

--- for a personal reply use: Luciano Notarfrancesco <luciano at corest.com>




More information about the Squeak-dev mailing list