formatting data in a field

Sarah Reichelt sarah.reichelt at gmail.com
Sat Apr 3 19:56:39 EDT 2010


On Sat, Apr 3, 2010 at 9:27 PM, David Coker <davidocoker at gmail.com> wrote:
> Hello folks,
> I seem to continually get hung up in areas that should be fairly simple by now.
> Here is the latest that I find myself banging my head over...
>
> <sigh>
> Lets say that I have two fields calculated where the sum contains
> something like 3.1666 as an example.
> What would be the proper way to format the display field as 3.16 ?
> </sigh>
>
> I've tried using both "format" and "numberFormat" in various ways
> without any luck so far
> As always, I certainly appreciate any and all help I get.

I prefer to use format. You then don't have to do the dummy
calculation to set it in place, and you know exactly what number it is
applying too, while numberFormat can end up applying to more numbers
than you expected.

So I woud use:
   put format("%.2f", 3.1666) into fld "Whatever"

Cheers,
Sarah



More information about the use-livecode mailing list