formatting data in a field

Sarah Reichelt sarah.reichelt at gmail.com
Sun Apr 4 19:36:07 EDT 2010


>> 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 would use:
>>   put format("%.2f", 3.1666) into fld "Whatever"
>
> That's exactly what I was trying to do and in fact looks very much the
> same as the way I was trying it. I think my misunderstanding has to do
> with how to use the 3.1666 which is stored in a variable. e.g.
>
> tCount = 3.166
> put format("%.2f", tCount) into fld "Whatever"
>
> In my situation, the actual value of the number involved is completely
> informational and of no great importance elsewhere. All I am trying to
> accomplish is to improve the appearance to the user.


I'm not quite sure what the problem is here David, but the line:
    tCount = 3.166
will not work, so I assume that was just you telling us what was in tCount.
If you are allocating a value to tCount, you would have to use:
    put 3.166 into tCount

Once you have done that, then the line you quoted:
    put format("%.2f", tCount) into fld "Whatever"
should work just fine.

Cheers,
Sarah



More information about the use-livecode mailing list