Barry
2008-02-29 08:02:40 UTC
Hi All
I am using this line of text to setup a default SAVE-As file name.
AnsiString TempName = "Wave_" + FloatToStr(Height) + "_" +
FloatToStr(Period) + "_" + FloatToStr(Location);
As you can see these values that are brought into the filename are
floats and not integers and sometimes contain one or more digits after
the decimal.
This works fine for 1 decimal floats, but often with two decimal floats,
and without formating, the default name could be as follows:
Wave_2.5_13.4499998092651_63.5400009155273.txt
How do I limit the decimals to 2, so as to retain neat filenames.
Normally I use
sprintf(tmpstr,"Wave_%4.2f_%4.1f_%5.2f",Height,Period,Location);
to format these floats to a string, but this method creates white spaces
infront of each number in the string, so does not work in a filename.
Any suggestions?
Thanks
Barry
I am using this line of text to setup a default SAVE-As file name.
AnsiString TempName = "Wave_" + FloatToStr(Height) + "_" +
FloatToStr(Period) + "_" + FloatToStr(Location);
As you can see these values that are brought into the filename are
floats and not integers and sometimes contain one or more digits after
the decimal.
This works fine for 1 decimal floats, but often with two decimal floats,
and without formating, the default name could be as follows:
Wave_2.5_13.4499998092651_63.5400009155273.txt
How do I limit the decimals to 2, so as to retain neat filenames.
Normally I use
sprintf(tmpstr,"Wave_%4.2f_%4.1f_%5.2f",Height,Period,Location);
to format these floats to a string, but this method creates white spaces
infront of each number in the string, so does not work in a filename.
Any suggestions?
Thanks
Barry