Insert and delete Commas

Ken Ray kray at sonsothunder.com
Sun Sep 29 02:26:01 EDT 2002


Robert,

> Ken, please excuse my delay in thanking you for your input.

No problem. :-)

>   Reading the applicable docs has not enabled me figure out how to
> implement Regular Expressions.  It will be appreciated if you would
> give an example of  how to implement
> ([-]?) etc. I assume a script is required.  If so, what would the
> script be and where would it be located?

These were attempts at explaining the full regular expression use of the
matchText function, in the post, which was:

function insertCommas pNumber
    local tMinusHold,tMainNum,tDecimalHold
    get
matchText(pNumber,"([-]?)([0-9]*)[\.]?([0-9]*)",tMinusHold,tMainNum,tDecimal
Hold)
    if it is true then  -- should be, but can't hurt to check
        put "" into returnVal
        if tDecimalHold <> "" then put "." before tDecimalHold
        repeat with x = length(tMainNum) down to 1
            if ((length(tMainNum) - x) mod 3 = 0) and (x <>
length(tMainNum)) then \
              put "," before returnVal
            put char x of tMainNum before returnVal
        end repeat
        return tMinusHold & tMainNum & tDecimalHold
    end if
end insertCommas

The code above is an example of the regular expression:

  ([-]?)([0-9]*)[\.]?([0-9]*)

which I described in the previous post.

I don't know what you mean by "I assume a script is required. If so, what
would the script be and where would it be located?"... can you elaborate?

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/




More information about the Use-livecode mailing list