extensions.st
changeset 4619 7e627429f1c6
parent 4528 844e085a7ac1
child 4620 df4699518c1b
equal deleted inserted replaced
4618:c68aee83ba0b 4619:7e627429f1c6
   368 
   368 
   369 printf:args
   369 printf:args
   370     "Format and print the receiver with <args> formatted in C style,
   370     "Format and print the receiver with <args> formatted in C style,
   371      as specified in the Unix C-language manual page for printf(3).
   371      as specified in the Unix C-language manual page for printf(3).
   372      Return the resulting string (i.e actually, this is more like an sprintf).
   372      Return the resulting string (i.e actually, this is more like an sprintf).
   373      For smalltalk specific formats, see documentation in PrintfScanf.
   373      For smalltalk specific formats, 
       
   374      see documentation in PrintfScanf >> format_printf.
   374      For copyright information, see goodies/String-printf_scanf.chg"
   375      For copyright information, see goodies/String-printf_scanf.chg"
   375 
   376 
   376     |aStream|
   377     |aStream|
   377 
   378 
   378     aStream := CharacterWriteStream on:(self species uninitializedNew:self size).
   379     aStream := CharacterWriteStream on:(self species uninitializedNew:self size).
   419 !CharacterArray methodsFor:'printing & storing'!
   420 !CharacterArray methodsFor:'printing & storing'!
   420 
   421 
   421 printf:args on:outStream
   422 printf:args on:outStream
   422     "Format and print the receiver on <outStream> with <args>
   423     "Format and print the receiver on <outStream> with <args>
   423      formatted in C style, as specified in the Unix C-language manual page for printf(3).
   424      formatted in C style, as specified in the Unix C-language manual page for printf(3).
   424      For smalltalk specific formats, see documentation in PrintfScanf.
   425      For smalltalk specific formats, 
       
   426      see documentation in PrintfScanf >> format_printf.
   425      For copyright information, see goodies/String-printf_scanf.chg"
   427      For copyright information, see goodies/String-printf_scanf.chg"
   426 
   428 
   427     PrintfScanf printf:self on:outStream arguments: args
   429     PrintfScanf printf:self on:outStream arguments: args
   428 
   430 
   429     "
   431     "
   447 
   449 
   448 printfWith:arg1
   450 printfWith:arg1
   449     "Format and print the receiver with <arg1> formatted in C style,
   451     "Format and print the receiver with <arg1> formatted in C style,
   450      as specified in the Unix C-language manual page for printf(3).
   452      as specified in the Unix C-language manual page for printf(3).
   451      Return the resulting string (i.e actually, this is more like an sprintf).
   453      Return the resulting string (i.e actually, this is more like an sprintf).
   452      For smalltalk specific formats, see documentation in PrintfScanf."
   454      For smalltalk specific formats, 
       
   455      see documentation in PrintfScanf >> format_printf"
   453 
   456 
   454     ^ self printf:(Array with:arg1)
   457     ^ self printf:(Array with:arg1)
   455 
   458 
   456     "
   459     "
   457      ('%05x' printfWith:123)
   460      ('%05x' printfWith:123)
   465 
   468 
   466 printfWith:arg1 with:arg2
   469 printfWith:arg1 with:arg2
   467     "Format and print the receiver with <argI> formatted in C style,
   470     "Format and print the receiver with <argI> formatted in C style,
   468      as specified in the Unix C-language manual page for printf(3).
   471      as specified in the Unix C-language manual page for printf(3).
   469      Return the resulting string (i.e actually, this is more like an sprintf).
   472      Return the resulting string (i.e actually, this is more like an sprintf).
   470      For smalltalk specific formats, see documentation in PrintfScanf."
   473      For smalltalk specific formats, see documentation in PrintfScanf >> format_printf."
   471 
   474 
   472     ^ self printf:(Array with:arg1 with:arg2)
   475     ^ self printf:(Array with:arg1 with:arg2)
   473 
   476 
   474     "
   477     "
   475      Transcript showCR:('%d %05x' printfWith:123 with:234)
   478      Transcript showCR:('%d %05x' printfWith:123 with:234)
   482 
   485 
   483 printfWith:arg1 with:arg2 with:arg3
   486 printfWith:arg1 with:arg2 with:arg3
   484     "Format and print the receiver with <argI> formatted in C style,
   487     "Format and print the receiver with <argI> formatted in C style,
   485      as specified in the Unix C-language manual page for printf(3).
   488      as specified in the Unix C-language manual page for printf(3).
   486      Return the resulting string (i.e actually, this is more like an sprintf).
   489      Return the resulting string (i.e actually, this is more like an sprintf).
   487      For smalltalk specific formats, see documentation in PrintfScanf."
   490      For smalltalk specific formats, see documentation in PrintfScanf >> format_printf."
   488 
   491 
   489     ^ self printf:(Array with:arg1 with:arg2 with:arg3)
   492     ^ self printf:(Array with:arg1 with:arg2 with:arg3)
   490 
   493 
   491     "
   494     "
   492      Transcript showCR:('%d %05x %08o' printfWith:123 with:234 with:345)
   495      Transcript showCR:('%d %05x %08o' printfWith:123 with:234 with:345)
   499 
   502 
   500 printfWith:arg1 with:arg2 with:arg3 with:arg4
   503 printfWith:arg1 with:arg2 with:arg3 with:arg4
   501     "Format and print the receiver with <argI> formatted in C style,
   504     "Format and print the receiver with <argI> formatted in C style,
   502      as specified in the Unix C-language manual page for printf(3).
   505      as specified in the Unix C-language manual page for printf(3).
   503      Return the resulting string (i.e actually, this is more like an sprintf).
   506      Return the resulting string (i.e actually, this is more like an sprintf).
   504      For smalltalk specific formats, see documentation in PrintfScanf."
   507      For smalltalk specific formats, see documentation in PrintfScanf >> format_printf."
   505 
   508 
   506     ^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4)
   509     ^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4)
   507 
   510 
   508     "
   511     "
   509      Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123)
   512      Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123)
   516 
   519 
   517 printfWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5
   520 printfWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5
   518     "Format and print the receiver with <argI> formatted in C style,
   521     "Format and print the receiver with <argI> formatted in C style,
   519      as specified in the Unix C-language manual page for printf(3).
   522      as specified in the Unix C-language manual page for printf(3).
   520      Return the resulting string (i.e actually, this is more like an sprintf).
   523      Return the resulting string (i.e actually, this is more like an sprintf).
   521      For smalltalk specific formats, see documentation in PrintfScanf."
   524      For smalltalk specific formats, see documentation in PrintfScanf >> format_printf."
   522 
   525 
   523     ^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5)
   526     ^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5)
   524 
   527 
   525     "
   528     "
   526      Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123)
   529      Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123)