I posted this one for someone a week or so ago that pads the output if necessary
print FormatNumber(123.456,6,2)
print FormatNumber(123.456,8,2)
print FormatNumber(-123.456,8,2)
wait key
function FormatNumber(Number as float, TotalSize as integer, DecimalPlaces as integer)
local FormattedDecimals as string
local FormattedNumber as string
FormattedDecimals = str$( abs( Number - int(Number) ) )
if len(FormattedDecimals) > 1
FormattedDecimals=right$(FormattedDecimals, len(FormattedDecimals)-1)
else
FormattedDecimals="."
endif
while len(FormattedDecimals) <= DecimalPlaces
FormattedDecimals = FormattedDecimals + "0"
endwhile
if len(FormattedDecimals) > DecimalPlaces+1 then FormattedDecimals = left$(FormattedDecimals, DecimalPlaces+1)
FormattedNumber = str$( int(Number) ) + FormattedDecimals
if len(FormattedNumber) < TotalSize
FormattedNumber = space$( TotalSize - len(FormattedNumber) ) + FormattedNumber
else
if len(FormattedNumber) > TotalSize then FormattedNumber = right$(FormattedNumber, TotalSize)
endif
endfunction FormattedNumber