{smcl}
{* 01oct2009}{...}
{cmd:help autofmt}

{hline}

{title:Title}

{p2colset 5 16 20 2}{...}
{p2col :{hi:  autofmt} {hline 2}}automatic formating of a significant number of digits{p_end}

{marker s_Syntax}
{title:Syntax}

{p 4 4 6}
{cmdab:autofmt}, {opt input(string)} {opt dec(#)} {opt parse(string)} {opt strict}]

{marker s_Description}
{title:Description}

{p 4 4 6}
{cmd:autofmt} provides a fast and easy way to format decimals to a significant number of 
digits. It will handle leading or trailing zeros. It will go into exponential format when the 
number is too small or too large.

{p 4 4 6}
The default setting is "plus-1" significant digits, meaning it will add one more digit if 
there is a digit to the left of decimals, i.e. 1.001 would be treated as 3-plus-1 digits. Use 
{opt strict} if you don't want this.

{p 4 4 6}
Whole numbers are left alone, as is the general practice, unless it is placed into exponential 
format.

{marker s_Options}
{title:Options}

{dlgtab:Main}

{p 4 12 6}{opt input(#)} a number to be formatted, can be multiple numbers.{p_end}

{p 4 12 6}{opt dec(#)} a number of significant digits. The default is dec(3).{p_end}

{p 4 12 6}{opt parse(string)} parse character. Only one accepted. The default is parse(" ").{p_end}

{p 4 12 6}{opt strict} strict number of significant digits. Don't do plus-1 number of digits.{p_end}

{marker s_0}
{title:Examples}

{p 4 8 6}. autofmt, input(-1.367456 -0.0000925 -0.5623 -13.5678) dec(2){p_end}
{p 4 8 6}. ret list{p_end}

{p 4 8 6}scalars:{p_end}
{p 13 8 6}             r(deci4) =  1{p_end}
{p 13 8 6}             r(deci3) =  2{p_end}
{p 13 8 6}             r(deci2) =  6{p_end}
{p 13 8 6}             r(deci1) =  2{p_end}

{p 4 8 6}macros:{p_end}
{p 11 8 6}           r(output4) : "-13.6"{p_end}
{p 12 8 6}            r(input4) : "-13.5678"{p_end}
{p 14 8 6}              r(fmt4) : "1f"{p_end}
{p 11 8 6}           r(output3) : "-0.56"{p_end}
{p 12 8 6}            r(input3) : "-0.5623"{p_end}
{p 14 8 6}              r(fmt3) : "2f"{p_end}
{p 11 8 6}           r(output2) : "-0.000092"{p_end}
{p 12 8 6}            r(input2) : "-0.0000925"{p_end}
{p 14 8 6}              r(fmt2) : "6f"{p_end}
{p 11 8 6}           r(output1) : "-1.37"{p_end}
{p 12 8 6}            r(input1) : "-1.367456"{p_end}
{p 14 8 6}              r(fmt1) : "2f"{p_end}


{title:Remarks}

{p 4 12 6}Based on codes from -outreg2-.{p_end}


{title:Author}

{p 4 4 6}Roy Wada{p_end}
{p 4 4 6}roywada@hotmail.com{p_end}


