+printStringLimitedTo:
authorClaus Gittinger <cg@exept.de>
Wed, 22 Sep 2004 11:16:59 +0200
changeset 8576 f58f51583a34
parent 8575 ed527f499503
child 8577 181fa2db957b
+printStringLimitedTo:
Object.st
--- a/Object.st	Wed Sep 22 10:17:27 2004 +0200
+++ b/Object.st	Wed Sep 22 11:16:59 2004 +0200
@@ -6699,6 +6699,22 @@
     "
 !
 
+printStringLimitedTo:sizeLimit
+    "return a string for printing the receiver, but limit the result string in its size."
+
+    |s|
+
+    s := CharacterWriteStream on:(String basicNew:30).
+    s writeLimit:sizeLimit.
+    self printOn:s.
+    ^ s contents.
+
+    "
+     Date today printStringLimitedTo:5.
+     '12345678901234567890' printStringLimitedTo:5. 
+    "
+!
+
 printStringOnError:exceptionBlock
     "return a string for printing the receiver; if any error occurs, return the result from
      evaluating exceptionBlock. Useful to print something in an exceptionHandler or other
@@ -9172,7 +9188,7 @@
 !Object class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.514 2004-09-22 07:22:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.515 2004-09-22 09:16:59 cg Exp $'
 ! !
 
 Object initialize!