--- a/Stream.st Thu May 16 16:51:10 1996 +0200
+++ b/Stream.st Fri May 17 08:59:00 1996 +0200
@@ -924,6 +924,8 @@
"read a collection of all objects up-to anObject and return these
elements, including anObject.
The next read operation will return the element after anObject.
+ If anObject is not encountered, all elements up to the end are read
+ and returned.
Compare this with #upTo: which also reads up to some object
and also positions behind it, but does not include it in the returned
value."
@@ -932,11 +934,11 @@
answerStream := WriteStream on:(self contentsSpecies new).
[self atEnd] whileFalse:[
- element := self next.
- answerStream nextPut:element.
- (element = anObject) ifTrue: [
- ^ answerStream contents
- ]
+ element := self next.
+ answerStream nextPut:element.
+ (element = anObject) ifTrue: [
+ ^ answerStream contents
+ ]
].
^ answerStream contents
@@ -945,19 +947,27 @@
s := ReadStream on:#(1 2 3 4 5 6 7 8).
Transcript showCr:(s through:4).
Transcript showCr:s next
- "
- "
+
+ |s|
+ s := ReadStream on:#(1 2 3 4 5 6 7 8).
+ Transcript showCr:(s through:9).
+ Transcript showCr:s next
+
|s|
s := ReadStream on:'hello world'.
Transcript showCr:(s through:Character space).
Transcript showCr:(s upToEnd)
"
+
+ "Modified: 17.5.1996 / 08:51:40 / cg"
!
upTo:anObject
"read a collection of all objects up-to anObject and return these
elements, but excluding anObject.
The next read operation will return the element after anObject.
+ If anObject is not encountered, all elements up to the end are read
+ and returned.
Compare this with #through: which also reads up to some object
and also positions behind it, but DOES include it in the returned
value."
@@ -966,11 +976,11 @@
answerStream := WriteStream on:(self contentsSpecies new).
[self atEnd] whileFalse:[
- element := self next.
- (element = anObject) ifTrue: [
- ^ answerStream contents
- ].
- answerStream nextPut:element.
+ element := self next.
+ (element = anObject) ifTrue: [
+ ^ answerStream contents
+ ].
+ answerStream nextPut:element.
].
^ answerStream contents
@@ -981,6 +991,11 @@
Transcript showCr:s next
|s|
+ s := ReadStream on:#(1 2 3 4 5 6 7 8).
+ Transcript showCr:(s upTo:9).
+ Transcript showCr:s next
+
+ |s|
s := ReadStream on:'hello world'.
Transcript showCr:(s upTo:Character space).
Transcript showCr:(s upToEnd)
@@ -992,10 +1007,12 @@
(ReadStream on:#(1 2 3 4 5 6)) upTo:4
(ReadStream on:'line 1
- line 2') upTo:Character cr
+ line 2') upTo:Character cr
'Makefile' asFilename readStream upTo:Character cr;upTo:Character cr
"
+
+ "Modified: 17.5.1996 / 08:51:56 / cg"
!
upToEnd
@@ -1261,6 +1278,6 @@
!Stream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.42 1996-05-15 16:09:14 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.43 1996-05-17 06:59:00 cg Exp $'
! !
Stream initialize!