Mucking around with unicodeText fields ???

Richmond Mathewson richmondmathewson at gmail.com
Mon Apr 5 14:33:24 EDT 2010


  Imagine, if you will, a field containing a fairly long string of 
unicodeText . . .

Now, some of the characters in the field (let's call it fld "FIRST") are 
in the wrong order . . .

And, we want to find the ones that are in the wrong places and move them 
into the right places
let's say in fld "SECOND" . . .

Now, my problem is that I can envisage this sort of script:

on mouseUp
    if the unicodeText in fld "FIRST" contains (numToChar(57888) & 
numToChar(57999)) then

    --- do something terribly clever that changes their order in the 
unicodeText and
    --- puts the whole unicodeText into fld "SECOND"

   end if
end mouseUp

but for the life of me I can't work out how to swap the chars round; 
this is extremely easy to do with
non-unicode text:

on mouseUp
put "CHEESE" into fld "THIRD"
    replace "EE" with "A" in fld "THIRD"
end mouseUp

this:

on mouseUp
    set the useUnicode to true
    if the unicodeText of fld "FIRST" contains (numToChar(57888) & 
numToChar(57999)) then
       replace the unicodeText(numToChar(57888) & numToChar(57999)) with 
the unicodeText(numToChar(57999) & numToChar(57888)) in fld "FIRST"
    end if
end mouseUp

does not work.

And this:

on mouseUp
    set the useUnicode to true
    if the unicodeText of fld "FIRST" contains (numToChar(57888) & 
numToChar(57999)) then
       replace (numToChar(57888) & numToChar(57999)) with 
(numToChar(57999) & numToChar(57888)) in fld "FIRST"
    end if
end mouseUp

de-unicodes the text in fld "FIRST, so I end up with a string of boxes.



More information about the use-livecode mailing list