Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!swrinde!emory!hubcap!ncrcae!ncrlnk!ncrwat!images1!jrl From: jrl@images1.Waterloo.NCR.COM (john Latala) Newsgroups: comp.sys.handhelds Subject: formatted output Message-ID: <735@ncrwat.Waterloo.NCR.COM> Date: 11 Jun 90 17:24:27 GMT Sender: news@ncrwat.Waterloo.NCR.COM Reply-To: john.Latala@Waterloo.NCR.COM Organization: NCR Canada Ltd, Waterloo, Ontario, Canada. Lines: 46 Keywords: One feature that I wish my HP28s did have was a way to do formatted output. It's a real pain when you're trying to display some numbers in a 'nice' way. It can be done eventually, with enough pushing and popping and setting the decimal point to the right number of places and a couple of ->STR and ->STR operations. But it does get a little bit cumbersome. How about a format command that takes a number and a format string from the stack and returns a string which is that number in that format. An unformat command that does the reverse would be nice, but not really needed. Initially I was thinking of something like the BASIC 'USING' clause: "#####.##" 123.456 FORMAT would return: " 123.47" The order of the arguments for the FORMAT command could even be optional, as long as it's a number and a string the usage can be figured out. It would be nice if it worked for any type (except string): (123.45, -234.45) "(####.##, ####.##)" FORMAT would return: "( 123.34, -234.45)" The format control string should have features to let it handle the usual 'formatting' features: - leading blank, "0" or any other character fill - leading zero suppression - variable width output (normal number to string with STD fmt) - various bases - floating minus sign - floating dollar sign are just a quick list of possible nice features. -- john.Latala@Waterloo.NCR.COM