Wildcard expressions and unicode ???

Peter Brigham MD pmbrig at gmail.com
Tue Apr 6 07:57:40 EDT 2010


Try this? Untested but should work. (The untested part is the first  
handler -- the offsets() function I have been using for years.)

on mouseup
    set the useUnicode to true
    put numtochar(57888) into targetChar
    put the unicodetext of fld "FIRST" into uText
    put offsets(targetChar,uText) into offsetList
    if offsetList = 0 then exit mouseup
    repeat for each item i in offsetList
       put char i+1 of uText & targetChar into \
                  char i to i+1 of uText
    end repeat
    set the unicodetext of fld "FIRST" to uText
end mouseup

function offsets str,cntr
    -- returns a comma-delimited list
    -- of all the offsets of str in cntr
    if str is not in cntr then return 0
    put "" into offsetList
    put 0 into startPoint
    repeat
       put offset(str,cntr,startPoint) into thisOffset
       if thisOffset = 0 then exit repeat
       add thisOffset to startPoint
       put startPoint & comma after offsetList
    end repeat
    delete last char of offsetList
    return offsetList
end offsets

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig



On Apr 6, 2010, at 5:09 AM, Richmond Mathewson wrote:

> I suppose it was inevitable . . .  :)
>
> As I wrote yesterday, I found out how to search for and replace  
> unicode characters
> in a field:
>
> on mouseUp
>   set the useUnicode to true
>   if the unicodeText of fld "FIRST" contains (numToChar(57888) &  
> numToChar(57999)) then
>      get the unicodeText of fld "FIRST"
>      replace (numToChar(57888) & numToChar(57999)) with  
> (numToChar(57999) & numToChar(57888)) in it
>      set the unicodeText of fld "FIRST" to it
>   end if
> end mouseUp
>
> which is jolly good, as far as it goes . . .
>
> However; suppose I wish to search for all instances of  
> numToChar(57888) in front of another unicode character
> and move them so that they are behind that unicode character . . .
>
> Let us imagine this sort of script: (where  ?  represents any, i.e.  
> wildcard, unicode character)
>
> on mouseUp
>   set the useUnicode to true
>   if the unicodeText of fld "FIRST" contains (numToChar(57888) & ?)  
> then
>      get the unicodeText of fld "FIRST"
>      replace (numToChar(57888) & ?)) with (? & numToChar(57888)) in it
>      set the unicodeText of fld "FIRST" to it
>   end if
> end mouseUp
>
> interestingly enough; on compiling in RunRev 4 it says that script  
> is OK (mind you it says that
> about lots of script that, on attempting to run, throw a "bluey"),
>
> Well, Ha, Ha; it is OK insofar as it does nothing!
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list