Insert and delete Commas

Jan Schenkel janschenkel at yahoo.com
Wed Sep 18 09:55:02 EDT 2002


Hi Bob,

If I understand these functions correctly, they place
thousand separators in numbers.
Since XTalk cannot process numbers with thousand
separators in them, they have to strip those commas
out before calculation.
After the calculations are done, when the data is
presented to the user on-screen, the thousand
separators are put back in, right?

You could always use Rob Cozen's Serendipity Library
for exactly that purpose :-)

However, the second function lends itself to
optimization very easily:

on deleteComma startNo, finishNo 
--syntax: deleteComma [integer, integer]
  repeat with x = startNo to finishNo
    replace "," with "" in fld x
  end repeat
end deleteComma

I'm sure we could provide you with a better version
for the insertCommaCd handler, but that would require
a bit more thinking than my flu-infested body can
muster right now.

Hope this helped nonetheless,

Jan Schenkel.

"As we grow older, we grow both wiser and more foolish
at the same time."  (De Rochefoucald)

--- Robert Presender <rpresender at earthlink.net> wrote:
> The following custom handlers(?) are used in an
> application developed 
> in SuperCard.
> They are used for math processes such as addition,
> subtraction, etc..  
> They work in Rev.
> 
> Would appreciate any comments relating to shorting
> or modifying the 
> scripts or a different approach.  The scripts are to
> be used on Mac and 
> Windows platforms.
> 
> Regards ... Bob
> 
> on insertCommaCd startNum, finishNum  --number must
> end in .00. 
> --syntax: insertCommaCd --[integer, integer]
>    repeat with x = startNum to finishNum
>      if char 1 of fld x  is "-" then
>        put "-" into minusHold
>        delete char 1 of  fld x
>      else
>        put "" into minusHold
>      end if
> 
>      if "," is not in fld x then
>        get the number of chars of  fld x
>        if it >= 7 and it <= 9 then
>          put "," after char (it -6) of  fld x
>        else
>          if it >= 10 then
>            get the number of chars of  fld x
>            put "," after char (it -9) of  fld x
>            put "," after char (it -5) of  fld x
>          end if
>        end if
>      end if
>      put minusHold before char 1 of  fld x
>    end repeat
> end insertCommaCd
> 
> --**Deletes commas from multiple or single  fields
> having 1 or
> --**more lines per  field. Minus numbers can be used
> on deleteComma startNo, finishNo --syntax:
> deleteComma [integer, 
> integer]
>    repeat with x = startNo to finishNo
>      get the number of lines of fld x
>      repeat with y = 1 to it
>        if "," is in line y of fld x then  --**
>          get offset(",", line y of fld x )
>          delete char it of line y of fld x
>          if it is not 0 then
>            get offset(",", line y of fld x )
>            delete char it of line y of fld x
>          else
>            next repeat
>          end if
>        end if
>      end repeat
>    end repeat
> end deleteComma


__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com



More information about the use-livecode mailing list