Insert and delete Commas

Robert Presender rpresender at earthlink.net
Wed Sep 18 17:54:01 EDT 2002


Hi Jan,
Thanks for your input.  Very helpful.  Hadn't thought of that approach 
for both delete and insert. Hope you are over the flu!
  Hope to include the suggestions in the conversion of my application 
"MyMonEE" to Rev.

Regards ... Bob

PS:  MyMonEE can be found at:
http://www.geocities.com/rpresender
If anyone on the list wants the Registration Code (free of course), 
just email me.
This also applies to Will Creator (done in Rev).

On Wednesday, September 18, 2002, at 09:01  AM, Jan Schenkel wrote:

> Hi Bob,
>
> During a rare "awake" moment I also rescripted your
> other handler. This should handle very long numbers
> better than the SuperCard functions, as well...
>
> on insertCommaCd startNum, finishNum
> --syntax: insertCommaCd --[integer, integer]
>   repeat with x = startNum to finishNum
>     put insertCommas(fld x) into fld x
>   end repeat
> end insertCommaCd
>
> function insertCommas pNumber
>   -- first strip off and save the sign
>   if char 1 of pNumber is "-" then
>     put "-" into tMinusHold
>     delete char 1 of pNumber
>   else
>     put "" into tMinusHold
>   end if
>   -- now strip off and save the decimal part
>   get offset(".", pNumber)
>   if it > 0 then
>     put char it to -1 into tDecimalHold
>     delete char it to -1 of pNumber
>   else
>     put "" into tDecimalHold
>   end if
>   -- now determine how many commas to place
>   put length(pNumber) into tLength
>   put (tLength DIV 3) into tCommas
>   if (tLength MOD 3) = 0 then subtract 1 from tCommas
>   -- insert the commas into the integer part
>   repeat with i = tCommas down to 1
>     put "," after char - (i * 3 + 1) of pNumber
>   end repeat
>   -- put everything back together
>   return tMinusHold & pNumber & tDecimalHold
> end insertCommas
>
>
> Hope this helped,
>
> Jan Schenkel.




More information about the use-livecode mailing list