- Joined
- Jul 9, 2006
- Messages
- 41
I was trying to write a function to round out numbers, and I came up with this:
It keeps giving me a syntax error on the first line, and I can't figure out why. Because of this, I have no clue whether it will work or not. Help!!!
function RoundTo takes real roundee, integer decimalplace returns integer rounded
local string a = R2S(roundee)
local string b
local integer product
if S2I(Substring( a, StringLength(a), StringLength(a) )) >=6 then
set b = SubString( a, 1, StringLength(a)-decimalplace-1 )+I2S(S2I(Substring( a, StringLength(a)-decimalplace, StringLength(a)))+1)+"0"
else
set b = Substring( a, 1, StringLength(a)-decimalplace ) +"0"
endif
set product = S2I(b)
return product
endfunction
It keeps giving me a syntax error on the first line, and I can't figure out why. Because of this, I have no clue whether it will work or not. Help!!!