RandomGenerator.st
changeset 1640 2c08e5efee48
parent 1606 ad25ac239337
child 1840 6cc7e54f6a62
--- a/RandomGenerator.st	Wed Jun 07 17:48:09 2006 +0200
+++ b/RandomGenerator.st	Wed Jun 14 12:04:24 2006 +0200
@@ -201,6 +201,27 @@
     "Modified: / 11.11.1999 / 09:52:26 / stefan"
 !
 
+nextCharacters:cnt
+    "get the next cnt printable characters.
+     We answer characters in the ascii range (codepoints 32 - 127)"
+
+    |bytes string|
+
+    bytes := self nextBytes:cnt.
+    string := String new:cnt.
+
+    bytes keysAndValuesDo:[:eachIndex :eachByte|
+        string at:eachIndex put:(Character value:(eachByte \\ 95 + 32)).
+    ].
+
+    ^ string
+
+
+    "
+      RandomGenerator new nextCharacters:8
+    "
+!
+
 nextInteger
     "return the next integral random number,
      in the range 0 .. 16r3FFFFFFF."
@@ -284,7 +305,7 @@
 !RandomGenerator class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/RandomGenerator.st,v 1.1 2006-03-10 08:51:39 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/RandomGenerator.st,v 1.2 2006-06-14 10:04:24 stefan Exp $'
 ! !
 
 RandomGenerator initialize!