Formating numbers in fields
Björnke von Gierke
bvg at mac.com
Thu Mar 11 11:33:15 EST 2010
no, you cannot set the numberformat of a field. what you can do is (for example) this:
on KeyUp --after someone entered something into the field
set the numberformat to "#.00"
put the selectedChunk of me into theTempSelection --retain selection
add 0 to me --force numberformat
select char (word 2 of theTempSelection) to (word 4 of theTempSelection) of me
end KeyUp
Note that this is a rather evil approach, mostly because there's no way to enter the right hand parts without using arrow navigation or mouse selection. Also, the code throws an error when a point or any non-number char is entered. Maybe it's more advantageous to use two fields, or only check on exitField and closeField, because there it's not as intrusive to interpret and remove wrong chars or double dots etc. but that of course depends on what you've actually planned.
Finally, these messages might also need to be handled:
on pasteKey
on cutKey
on closeField
On 11 Mar 2010, at 17:16, Andrew Kluthe wrote:
>
> I tried setting that property and I must not know how to use it properly
> because I could not figure it or the documentation on it out.
>
> Do I set this as a property of the field and it handles all that for me? or?
>
>> From the dictionary:
>
> Examples:
> set the numberFormat to "#.00" -- dollar format
> set the numberFormat of scrollbar "Progress" to "0.0"
>
>
> so "set the numberFormat of fld "fLeasePaymentDollars tp "#.##"" doesn't
> work. How do I use this thing?
> --
> View this message in context: http://n4.nabble.com/Formating-numbers-in-fields-tp1589177p1589213.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list