anixon Posted August 19, 2009 Share Posted August 19, 2009 (edited) Using this code: $Value = StringFormat('%.2f', 0.00) FileWriteLine($File, $Value) $Value = StringFormat('%.2f', 10.00) FileWriteLine($File, $Value) This is achieved 0.00 10.00 What is the magic to format the numbers to appear in correct column format Ant.. Edited August 19, 2009 by anixon Link to comment Share on other sites More sharing options...
Bowmore Posted August 19, 2009 Share Posted August 19, 2009 Using this code: $Value = StringFormat('%.2f', 0.00) FileWriteLine($File, $Value) $Value = StringFormat('%.2f', 10.00) FileWriteLine($File, $Value) This is achieved 0.00 10.00 What is the magic to format the numbers to appear in correct column format Ant.. Try this, although it will only really give you what you want with a mono spaced font $Value = StringFormat('%.2f', 0.00) FileWriteLine($File, $Value) $Value = StringFormat('%.2f', 10.00) FileWriteLine($File, $Value) "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
anixon Posted August 19, 2009 Author Share Posted August 19, 2009 Try this, although it will only really give you what you want with a mono spaced font $Value = StringFormat('%.2f', 0.00) FileWriteLine($File, $Value) $Value = StringFormat('%.2f', 10.00) FileWriteLine($File, $Value) I am using the same code as per your example so I guess the question is what is a typical mono font. I am currently using Global $Font = "times new roman", $FontSize = 10, $FontWeight = 400 Ant.. Link to comment Share on other sites More sharing options...
Bowmore Posted August 19, 2009 Share Posted August 19, 2009 I am using the same code as per your example so I guess the question is what is a typical mono font. I am currently using Global $Font = "times new roman", $FontSize = 10, $FontWeight = 400 Ant.. Sorry I posted the wrong code in my first reply. $Value = StringFormat('%6.2f', 0.00) FileWriteLine($File, $Value) $Value = StringFormat('%6.2f', 10.00) FileWriteLine($File, $Value) "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
anixon Posted August 20, 2009 Author Share Posted August 20, 2009 Sorry I posted the wrong code in my first reply. $Value = StringFormat('%6.2f', 0.00) FileWriteLine($File, $Value) $Value = StringFormat('%6.2f', 10.00) FileWriteLine($File, $Value) What does the 6 actually do in '%6.2f' as it does appear to have an explaination within the documentation. I noticed that 0 as a flag can be used as width padding. Ant.. Link to comment Share on other sites More sharing options...
Malkey Posted August 20, 2009 Share Posted August 20, 2009 What does the 6 actually do in '%6.2f' as it does appear to have an explaination within the documentation. I noticed that 0 as a flag can be used as width padding. Ant.. The "6" is the total number of characters. ; $Value = StringFormat('%6.2f', 0.00) ConsoleWrite($Value & " <== 6 characters in total" & @CRLF) $Value = StringFormat('%6.2f', 123.56) ConsoleWrite($Value & " <== 6 characters in total" & @CRLF) $Value = StringFormat('%7.2f', 123.56) ConsoleWrite($Value & " <== 7 characters in total (1st character a space)" & @CRLF) ; Link to comment Share on other sites More sharing options...
anixon Posted August 21, 2009 Author Share Posted August 21, 2009 The "6" is the total number of characters. ; $Value = StringFormat('%6.2f', 0.00) ConsoleWrite($Value & " <== 6 characters in total" & @CRLF) $Value = StringFormat('%6.2f', 123.56) ConsoleWrite($Value & " <== 6 characters in total" & @CRLF) $Value = StringFormat('%7.2f', 123.56) ConsoleWrite($Value & " <== 7 characters in total (1st character a space)" & @CRLF) ; Ahhh that makes sense to ensure the correct justification you just increase the number to accommodate thousands, 10's of thousands etc. So much to learn so little time. Appreciate your explaination Ant.. an AusVicMex Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now