I created these two custom functions to use until the built-in functions are fixed, which should be in the next Sesame release. There's an article that I wrote for Inside Sesame (June 2005, Page 17) that covers the rounding problem and the reason for it.
Since you are using commas instead of periods for the decimal symbol, you will need change the periods to commas at the appropriate places within the code.
Let me know how you make out.
//########## Begin Custom Decimals Function ##########
// @cuDecimals(V, P)
// Parameters: V as Double, P as Integer
// Returns: String
Function @cuDecimals(Value as double, Places as int) as string
var vStr as string = @Str(Value)
if @Instr(vStr, ".") > 0
vStr = vStr + "000000"
else
vStr = vStr + ".000000"
vStr = @Del(vStr, @Instr(vStr, ".") + Places + 1, 10)
Return vStr
End Function
//########## End Custom Decimals Function ##########
//########## Begin Custom Rounding Function ##########
// @cuRND(V, P)
// Parameters: V as Double, P as Integer
// Returns: Double
// Rounds off the value of V to P decimal places. Unlike the regular @RND function, the value
// of P must be a positive number, meaning that it is only designed to round to whole numbers
// or to tenths, hundredths, thousandths, etc. - not to the nearest tens, hundreds, etc.
Function @cuRND(Value as double, Places as int) as double
var vNeg as int //Used to handle Negatives properly
var vStr as string
if Value < 0
vNeg = -1
else
vNeg = 1
vStr = @Str(@Abs(Value))
if @Instr(vStr, ".") > 0 //Protects whole numbers when rounding to zero places
{
if @Mid(vStr, @Instr(vStr, ".") + Places + 1, 1) >= 5
vStr = @Str( @TN(vStr) + (1 / @Exp(10, Places)) )
vStr = @Del(vStr, @Instr(vStr, ".") + Places + 1, 10)
}
vStr = @Str(@TN(vStr) * vNeg)
Return @TN(vStr)
End Function
//########## End Custom Rounding Function ##########