--- a/TextCollector.st Sat Jan 23 06:59:40 2016 +0100
+++ b/TextCollector.st Sun Jan 24 06:56:50 2016 +0100
@@ -770,7 +770,21 @@
!
format:formatSpec with:args
+ "convenient formatted printing:
+ %1..%9 - positional parameters from args-collection
+ %(name) - named parameter from args-dictionary
+ %% - escape for %
+ %<cr> - cr (also tab, nl)"
+
^ entryStream format:formatSpec with:args
+
+ "
+ 1 to: 10 do:[:i |
+ Transcript
+ format:'[%1] Hello %2 World - this is %3%<cr>'
+ with:{i . 'my' . 'nice'}
+ ].
+ "
!
lineLength
@@ -844,6 +858,85 @@
"Modified: 11.1.1997 / 14:43:26 / cg"
!
+printf:formatSpec with:arg1
+ "convenient C-style formatted printing"
+
+ ^ entryStream printf:formatSpec with:arg1
+
+ "
+ 1 to: 10 do:[:i |
+ Transcript
+ printf:'[%d] Hello World\n' with:i
+ ].
+ "
+!
+
+printf:formatSpec with:arg1 with:arg2
+ "convenient C-style formatted printing"
+
+ ^ entryStream printf:formatSpec with:arg1 with:arg2
+
+ "
+ 1 to: 10 do:[:i |
+ Transcript
+ printf:'[%d] Hello World\n' with:i
+ ].
+ "
+!
+
+printf:formatSpec with:arg1 with:arg2 with:arg3
+ "convenient C-style formatted printing"
+
+ ^ entryStream printf:formatSpec with:arg1 with:arg2 with:arg3
+
+ "
+ 1 to: 10 do:[:i |
+ Transcript
+ printf:'[%d] Hello World\n' with:i
+ ].
+ "
+!
+
+printf:formatSpec with:arg1 with:arg2 with:arg3 with:arg4
+ "convenient C-style formatted printing"
+
+ ^ entryStream printf:formatSpec with:arg1 with:arg2 with:arg3 with:arg4
+
+ "
+ 1 to: 10 do:[:i |
+ Transcript
+ printf:'[%d] Hello World\n' with:i
+ ].
+ "
+!
+
+printf:formatSpec with:arg1 with:arg2 with:arg3 with:arg4 with:arg5
+ "convenient C-style formatted printing"
+
+ ^ entryStream printf:formatSpec with:arg1 with:arg2 with:arg3 with:arg4 with:arg5
+
+ "
+ 1 to: 10 do:[:i |
+ Transcript
+ printf:'[%d] Hello World\n' with:i
+ ].
+ "
+!
+
+printf:formatSpec withAll:args
+ "convenient C-style formatted printing"
+
+ ^ entryStream printf:formatSpec withAll:args
+
+ "
+ 1 to: 10 do:[:i |
+ Transcript
+ printf:'[%d] Hello %s World - this is %s\n'
+ with:{i . 'my' . 'nice'}
+ ].
+ "
+!
+
println
"for those used to Java/Javascript, a compatibility message.
Most useful inside expecco"