curious behavior...
Jan Schenkel
janschenkel at yahoo.com
Sat May 29 05:43:49 EDT 2004
--- jcwall at jaguar1.usouthal.edu wrote:
> Slightly off topic but to do with numberFormat.
>
> I have had some difficulties with this property
> which I have managed to get around. I needed to do
> some calculations and enter the result in a field
> limiting the number to two decimal places. Set the
> numberFormat to "0.00" works as documented. My
> difficulty came when I needed to do calculations
> within a repeat loop e.g.
>
> set the numberFormat to "0.00"
> put 1 into i
> repeat 3
> put "ETGUG" & i into x
> add fld x to fld "Answer"
> add 1 to i
> end repeat
>
> Because of the numberFormat instead of x being
> ETGUG1 as I had hoped because that is the name of
> the field thet I wanted, it becomes ETGUG1.00 and
> since there is no field ETGUG1.00 the script fails.
> As I said, I have managed to solve the problem by
> constantly changing the numberFormat property so
> this is not a pressing issue. However, it was messy
> and I thought that if it were possible to set the
> number format of the field this would simplify the
> process. I tried set the numberForma
> t of fld "ETGUG1" but, as documented, this does not
> work. Does anyone know if there is some way to
> accomplish this?
>
> Jim Wall
>
Hi Jim,
I usually do all calculations before applying any
formatting ; and then I use the format() function ; in
this case :
--
put 1 into i
repeat 3
put "ETGUG" & i into x
add fld x to tAnswer
add 1 to i
end repeat
put format(tAnswer,"%.2f") into field "Answer"
--
Hope this helped,
Jan Schenkel.
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
More information about the use-livecode
mailing list