Insert and delete Commas

Robert Presender rpresender at earthlink.net
Wed Sep 18 08:26:01 EDT 2002


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




More information about the use-livecode mailing list