[Newbies] Number formatting printf/sprintf for Squeak?
David Finlayson
david.p.finlayson at gmail.com
Tue Feb 17 17:42:07 UTC 2009
There are also some interesting examples of string formatting in the
DateAndTime class used for printing hours minutes and seconds onto a
stream. That's where I picked up how Squeak does it (painful I might
add).
printf (or Java's String.format) are nice. Python has some nice ideas
here too. Maybe some Smalltalk guru could shed some light on the one
true way to do this?
David
On Mon, Feb 16, 2009 at 7:15 PM, Sorensen <sorens at surfy.net> wrote:
>
> Thanks everybody for your replies. I'll look at SBE and Seaside 2.9 as well
> for further examples.
>
>> For left-justifying text, I'm a bit surprised that you'd want to do this.
>> Typically, you'd make the text left
>> or right justified in whatever GUI element that value ends up in, rather
>> than padding it with spaces.
>
> You're right. I'd like to do more than simply left-justify:
>
> "%6.2f" 34.56 "space-padded right justified"
> "%-6.2f" 34.56 "space-padded left justified"
> "%02d" 05 "zero padded left justified"
>
> etc
>
> Your examples though gave me a good place to start.
>
> Many thanks
>
>
> Sorensen wrote:
>>
>> Is there a printf/sprintf-like package for formatting text for Squeak?
>>
>> If not, how do Squeakers go about formatting currency amounts or left
>> justifying text within a field?
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Number-formatting-printf-sprintf-for-Squeak--tp22045889p22049206.html
> Sent from the Squeak - Beginners mailing list archive at Nabble.com.
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
--
David Finlayson, Ph.D.
Operational Geologist
U.S. Geological Survey
Pacific Science Center
400 Natural Bridges Drive
Santa Cruz, CA 95060, USA
Office: 831-427-4757
Lab: 831-427-4462
Fax: 831-427-4748
E-mail: dfinlayson at usgs.gov
More information about the Beginners
mailing list