ReadWriteStream.st
changeset 5309 fa0d92f438db
parent 3081 4cd54c54ed78
child 5932 6041c11b3370
--- a/ReadWriteStream.st	Tue Mar 21 13:52:01 2000 +0100
+++ b/ReadWriteStream.st	Tue Mar 21 13:53:43 2000 +0100
@@ -49,6 +49,17 @@
     [author:]
         Claus Gittinger
 "
+!
+
+examples
+"
+    |s|
+
+    s := ReadWriteStream with:'abcd'.
+    s reset.
+    s nextPut:$A.
+    s contents       
+"
 ! !
 
 !ReadWriteStream methodsFor:'access-reading'!
@@ -86,11 +97,18 @@
      ST80 users if RWStream expect the contents array to remain
      unchanged."
 
-    readLimit := readLimit max:position-1.
+    readLimit := (readLimit ? 0) max:position-1.
     ^ collection copyFrom:1 to:readLimit
 
     "Created: / 30.10.1997 / 16:25:22 / cg"
     "Modified: / 30.10.1997 / 18:37:09 / cg"
+!
+
+reset
+    "set the read position to the beginning of the collection"
+
+    self resetPosition
+
 ! !
 
 !ReadWriteStream methodsFor:'converting'!
@@ -103,15 +121,17 @@
     "Created: 29.11.1995 / 22:04:23 / stefan"
 ! !
 
-!ReadWriteStream methodsFor:'positioning'!
+!ReadWriteStream methodsFor:'initialization'!
 
-reset
-    "set the read position to the beginning of the collection.
-     Re-redefined to prevent the collection from being emptied."
+on:initialCollection
+    super on:initialCollection.
+    readLimit := 0.
+!
 
-    position := "0" 1
-
-    "Created: / 30.10.1997 / 16:17:45 / cg"
+with:initialCollection
+    super with:initialCollection.
+    readLimit := initialCollection size.
+    position := 1.
 ! !
 
 !ReadWriteStream methodsFor:'queries'!
@@ -125,5 +145,5 @@
 !ReadWriteStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.19 1997-11-02 17:52:46 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.20 2000-03-21 12:53:43 cg Exp $'
 ! !