Page 1 of 1

numbers ending in only .0

Posted: Tue Oct 13, 2009 10:26 pm
by TodayIsTheDay
I have this on a card:

Code: Select all

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??

Posted: Tue Oct 13, 2009 10:50 pm
by gyroscope
Hi TodayIsTheDay

I guess it has to be coded. the following seems to work OK:

Code: Select all

  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.

:)

Posted: Tue Oct 13, 2009 11:07 pm
by bn
Hi TodayIsTheDay,

you could also set the numberformat before you do your calculation (dictionary)

Code: Select all

set the numberFormat to "#.00"
regards
Bernd

Posted: Tue Oct 13, 2009 11:19 pm
by TodayIsTheDay
Thanks! I'll take a look at both of these solutions. I love having more than one option....

Posted: Wed Oct 14, 2009 9:08 am
by Klaus
Hi,

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" ;-)


Best

Klaus