numberFormat prop
Sarah
sarahr at genesearch.com.au
Tue Jul 9 18:02:01 EDT 2002
It is often necessary to do a fake calculation to force the numberFormat
to be applied.
Try this script:
put "123.56789" into theNum
set the numberFormat to "#.00"
answer theNum -- gives 123.56789
add 0 to theNum
answer theNum -- gives 123.57
You can't apply a numberFormat to a field but you can take the number
out of the field, format it and put it back again, perhaps in a
closeField handler.
Cheers,
Sarah
On Wednesday, July 10, 2002, at 06:42 AM, Steve Messimer wrote:
> Rob,
>
>>> Anybody know how to set the decimal precision of a numeric value? I
>>> have
>>> looked through the docs but I can't seem to find the reference.
>>
>> Hi Steve,
>>
>> Did you check the numberFormat property?
>
> After thrashing around a bit I did find the numberFormat property on my
> own.
> For some reason I was unable to get it to work correctly. I think the
> issue
> had to do with how and to what type of container it can be applied. I
> presumed that it can be applied to any container.
>
> I tried:
>
> set the numberFormat of fld "myFld" to "00.0" -- (and 00.0 and "##.#")
> none
> of which worked
>
> then I tried:
>
> set the numberFormat of calcHolder to 00.0 -- where calcHolder is a var.
> (also tried 00.0 and "##.#") didn't work either
>
> Finally, I just trunc'd the dang thing and I got pretty much what I was
> aiming for. I decided I really didn't need the decimal after all.
>
> put trunc(calcHolder * 100) into fld "myFld"
>
> That having been said it would be nice to see an example of how the
> numberFormat should work. :-) Any examples will be much appreciated.
>
> Regards,
>
> Steve
>
> Stephen R. Messimer
> Messimer Computing, Inc
> 208 1st Ave South
> Escanaba, MI 49829
> www.messimercomputing.com
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list