I want it so that if user leaves textfield blank, it will be changed before undergoing rounding so that it has an actual number to work with rather than nil. But what I think is happening is that it gets to the rounding string before the " " is turned into 0 which then causes the error. So I want to know if someone with more experience will know of an easy way to get around this.
Also inputType for the textField is “number” if that helps.
[lua]
local function automaticCalculation (event)
if ( “submitted” == event.phase ) or (“ended” == event.phase) then
native.setKeyboardFocus( nil )
event.phase = “ended”
if (box1P.text == “”) then
box1P.text = 0
end
box1Rounded.text = string.format ("%.2f", (math.round (((tonumber(box1P.text))))
end
end
[/lua]
Error saying doing arithmetic on nil value.
Thanks!