keyInField
Jan Schenkel
janschenkel at yahoo.com
Thu Sep 26 20:57:00 EDT 2002
Hi Yves et al,
Of course I had to leave a typo in this "definitive"
version *grumble*
Replace the script of function Conv4Disp with:
function Conv4Disp pNumber
-- convert to the chosen floating point format
put the uFormat of me into tFormat
if tFormat is empty then put "%16.2f" into tFormat
put format(tFormat, pNumber) into tNumber
-- remove leading spaces
put 1 into tStart
repeat while char tStart of tNumber = " "
add 1 to tStart
end repeat
-- and the next line was wrong of course
-- put char tStart to -1 of pNumber into tNumber
put char tStart to -1 of tNumber into tNumber
-- prepare the display format
-- thanks to Ken Ray for this RegExp :-)
local tMinusHold,tMainNumber,tDecimalHold
get matchText(tNumber, \
"([-]?)([0-9]*)[\.]?([0-9*)", \
tMinusHold, tMainNumber, tDecimalHold)
-- tweak tDecimalHold
put the uDecimalPoint of me into tDecPoint
if tDecPoint is empty then put "." into tDecPoint
if tDecimalHold is not empty then put tDecPoint \
before tDecimalHold
-- now determine how many separators to place
put the uThousandSeparator of me into t1000Sep
if t1000Sep is not empty then
put length(tMainNumber) into tLength
put (tLength DIV 3) into tSeps
if (tLength MOD 3) = 0 then subtract 1 from tSeps
-- insert the commas into the integer part
repeat with i = tSeps down to 1
put t1000Sep after char - (i * 3 + 1) of \
tMainNumber
end repeat
end if
-- put everything back together
return tMinusHold & tMainNumber & tDecimalHold
end Conv4Calc
---
Hope this helped,
Jan Schenkel.
"As we grow older, we grow both wiser and more foolish
at the same time." (De Rochefoucald)
__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
More information about the use-livecode
mailing list