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!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
TodayIsTheDay
- Posts: 56
- Joined: Sat Jun 20, 2009 2:41 pm
Post
by TodayIsTheDay » Tue Oct 13, 2009 10:26 pm
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??
-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Tue Oct 13, 2009 10:50 pm
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.

Last edited by
gyroscope on Tue Oct 13, 2009 11:08 pm, edited 1 time in total.
-
bn
- VIP Livecode Opensource Backer

- Posts: 4163
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Tue Oct 13, 2009 11:07 pm
Hi TodayIsTheDay,
you could also set the numberformat before you do your calculation (dictionary)
regards
Bernd
-
TodayIsTheDay
- Posts: 56
- Joined: Sat Jun 20, 2009 2:41 pm
Post
by TodayIsTheDay » Tue Oct 13, 2009 11:19 pm
Thanks! I'll take a look at both of these solutions. I love having more than one option....
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Wed Oct 14, 2009 9:08 am
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