class: Stream
authorClaus Gittinger <cg@exept.de>
Thu, 15 Mar 2018 22:45:28 +0100
changeset 4620 df4699518c1b
parent 4619 7e627429f1c6
child 4621 800bea9535cd
class: Stream comment/format in: #printf: #printf:arguments: #printf:with: #printf:with:with: #printf:with:with:with: #printf:with:with:with:with: #printf:with:with:with:with:with: #printf:withAll:
extensions.st
--- a/extensions.st	Thu Mar 15 22:42:34 2018 +0100
+++ b/extensions.st	Thu Mar 15 22:45:28 2018 +0100
@@ -1389,6 +1389,128 @@
     "
 ! !
 
+!Stream methodsFor:'writing'!
+
+printf:format
+    "C-style printing into a stream.
+     For smalltalk specific formats, 
+     see documentation in PrintfScanf >> format_printf"
+
+    format printf:#() on:self.
+
+    "
+     Transcript printf:'Hello World\n'
+    "
+! !
+
+!Stream methodsFor:'writing'!
+
+printf:format arguments:arguments
+    "C-style printing into a stream.
+     Same as printf:withAll:, for protocol completeness.
+     For smalltalk specific formats, 
+     see documentation in PrintfScanf >> format_printf"
+
+    format printf:arguments on:self.
+
+    "
+     Transcript printf:'%05x %d %f %o\n' withAll:{ 123. 234*5. 1.234. 8r377 }
+     Transcript printf:'%03d %03d %03d\n' withAll:{ 1. 2. 3 }
+    "
+
+    "Created: / 23-02-2017 / 16:43:39 / cg"
+! !
+
+!Stream methodsFor:'writing'!
+
+printf:format with:argument
+    "C-style printing into a stream.
+     For smalltalk specific formats, 
+     see documentation in PrintfScanf >> format_printf"
+
+    format printf:{argument} on:self.
+
+    "
+     Transcript printf:'%05x\n' with:12345
+    "
+! !
+
+!Stream methodsFor:'writing'!
+
+printf:format with:argument1 with:argument2
+    "C-style printing into a stream.
+     For smalltalk specific formats, 
+     see documentation in PrintfScanf >> format_printf"
+
+    format printf:{argument1 . argument2} on:self.
+
+    "
+     Transcript printf:'%05x %3s\n' with:12345 with:'abc'
+    "
+! !
+
+!Stream methodsFor:'writing'!
+
+printf:format with:argument1 with:argument2 with:argument3
+    "C-style printing into a stream.
+     For smalltalk specific formats, 
+     see documentation in PrintfScanf >> format_printf"
+
+    format printf:{argument1 . argument2 . argument3} on:self.
+
+    "
+     Transcript printf:'%05x %3s %09s\n' with:12345 with:'abc' with:'abc'
+     Transcript printf:'%05x %3s %9s\n' with:12345 with:'abc' with:'abc'
+    "
+! !
+
+!Stream methodsFor:'writing'!
+
+printf:format with:argument1 with:argument2 with:argument3 with:argument4
+    "C-style printing into a stream.
+     For smalltalk specific formats, 
+     see documentation in PrintfScanf >> format_printf"
+
+    format printf:{argument1 . argument2 . argument3 . argument4} on:self.
+
+    "
+     Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4
+     Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4
+     Transcript printf:'%-2x %-2x %-2x %-2x\n' with:1 with:2 with:3 with:4
+    "
+! !
+
+!Stream methodsFor:'writing'!
+
+printf:format with:argument1 with:argument2 with:argument3 with:argument4 with:argument5
+    "C-style printing into a stream.
+     For smalltalk specific formats, 
+     see documentation in PrintfScanf >> format_printf"
+
+    format printf:{argument1 . argument2 . argument3 . argument4 . argument5} on:self.
+
+    "
+     Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4
+     Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4
+     Transcript printf:'%-2x %-2x %-2x %-2x\n' with:1 with:2 with:3 with:4
+    "
+! !
+
+!Stream methodsFor:'writing'!
+
+printf:format withAll:arguments
+    "C-style printing into a stream.
+     For smalltalk specific formats, 
+     see documentation in PrintfScanf >> format_printf"
+
+    format printf:arguments on:self.
+
+    "
+     Transcript printf:'%05x %d %f %o\n' withAll:{ 123. 234*5. 1.234. 8r377 }
+     Transcript printf:'%03d %03d %03d\n' withAll:{ 1. 2. 3 }
+    "
+! !
+
 !Stream methodsFor:'stacked computing streams'!
 
 selecting:aBlock