Page 1 of 1

number formatting

Posted: Mon Oct 07, 2013 2:24 am
by byg
Hi, I thought this would be easy but no. Basically I would like to be able to format a number to display a currency in this case dollar ex. $123.45
I read the information in dictionary and search thru the forum for number formatting and glance thru apps examples with not much success. Any help on this would be appreciated, tutorial, guide to read anything. I build a test stack to see how formatting would work. The example below does not give me an error but if I enter 123.4567 I get 123.4567 in both cases.TIA





on mouseUp
set the numberformat to "0.00"
ask "enter a number"
put it into field "mine"
answer it
end mouseUp

Re: number formatting

Posted: Mon Oct 07, 2013 2:43 am
by Simon
Hi byg,
Here is the funny little line in the dictionary that gets overlooked:
Use the numberFormat property to specify the results of numeric calculations,
Note the last 5 words :)

I think this will do it:
on mouseUp
set the numberformat to "0.00"
ask "enter a number"
add 0 to it
put it into field "mine"
answer it
end mouseUp

Re: number formatting

Posted: Mon Oct 07, 2013 2:46 am
by dunbarx
Hi right back to you.

An oldie but goodie. The numberformat property will not express itself unless an arithmetic operation is performed first. Try this:

Code: Select all

on mouseUp
set the numberformat to "0.00"
ask "enter a number"
answer it + 0
end mouseUp
The addition seems superfluous, and in every sense except making the format work, it is.

Craig Newman

Re: number formatting

Posted: Mon Oct 07, 2013 3:21 am
by byg
hI to both of you , amazingly simple when you know it, "overlook" is right , thanks all.
byg