- Code: Select all
writeVar("test123_", 98.897896875578)
on writeVar(indigoSensor, val)
tell application "IndigoServer"
set val to my (roundThis(val, 2))
set value of variable indigoSensor to val
end tell
end writeVar
on roundThis(n, numDecimals)
set multiplier to 10 ^ numDecimals
n * multiplier
round result
result / multiplier
end roundThis
If I round off the number with the roundThis script first then have Indigo write the value to a variable it still won't round it off to two decimal places.
- Code: Select all
set val to 99.897896875578
set val to my roundThis(val, 2)
--return val ==> returns rounded off value correctly
writeVar("test123_", val)
on writeVar(indigoSensor, val)
tell application "IndigoServer"
set value of variable indigoSensor to val
end tell
end writeVar
on roundThis(n, numDecimals)
set multiplier to 10 ^ numDecimals
n * multiplier
round result
result / multiplier
end roundThis