LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
on mouseUp
put field "FeetWide" into FeetWide
put field "FeetLong" into FeetLong
put FeetWide*FeetLong into TotalSqFt
put TotalSqFt into field "TotalSqFt"
Put TotalSqFt * ChargePerSqFt / 1000 into Field "TotalToCharge"
end mouseUp
It works like it should except the numbers end like $1.8, $1.4, etc. There is no zero. i.e.- $1.80, $1.40
Is there a setting for numbers I'm overlooking or do I need to code something for this??
put field "FeetWide" into FeetWide
put field "FeetLong" into FeetLong
put FeetWide*FeetLong into TotalSqFt
put TotalSqFt into field "TotalSqFt"
put "15" into ChargePerSqFt --- guess ;)
Put TotalSqFt*ChargePerSqFt/1000 into tSum
if char -2 of tSum= "." then put "0" after tSum
if char -4 of tSum="." then delete char -1 of tSum
if (tSum contains ".") is false then put tSum&"."&"00" after tSum
put tSum into Field "TotalToCharge"
Hope that's helpful.
Last edited by gyroscope on Tue Oct 13, 2009 11:08 pm, edited 1 time in total.
you can also us "format" to format your number(s):
...
put format("%1.2f",your_variable_with_the_sum) into fld "total"
...
Where "f" stands for "floating" and 1.2 stands for at least one digit before (0.xx) and 2 digits after the decimal point.
One of the few things I understood about "format"