Manipulating PLAIN text on the clipboard

JonathanC at ag.nsw.gov.au JonathanC at ag.nsw.gov.au
Mon Mar 8 19:38:59 EST 2004


I have some scripts that manipulate text on the clipboard (turn text to 
uppercase/lowercase etc., add up a column of numbers, wrap/unwrap text 
etc.) but I can't seem to get them to leave the text as PLAIN text.

Here's one of them:

on mouseUp
  put the clipboardData["text"] into temp
  set the clipboardData["text"] to wrap(temp,75)
end mouseUp

No matter where I copy the text FROM, no matter what font and size it was, 
it always ends up after pasting (assuming I paste it into an application 
that supports styled text) as Lucida Grande, 11pt.

I'm sure the short script above is where the problem lies, but just in 
case, here's the function it calls:

function wrap str,n
  put "" into newStr
  repeat with i=1 to the number of lines in str
    put line i of str into para
    if para = "" then
      put return after newStr
      next repeat
    end if
    put "" into newPara
    repeat
      put char 1 to n of para into lineTemp
      if the length of lineTemp < n then
        -- no more para
        put return & lineTemp after newPara
        exit repeat
      end if
      put the number of words in lineTemp into wordCount
      put return & (word 1 to wordCount-1 of para) after newPara
      delete word 1 to wordCount-1 of para
    end repeat
    delete char 1 of newPara -- return
    put return & newPara after newStr
  end repeat
  delete char 1 of newStr -- return
  return newStr
end wrap

(I'm using Rev 2.1.2 on a PowerBook G4 running OS X 10.2.8.)

Thanks,

Jonathan Cooper
Manager of Information / Website
Art Gallery of New South Wales
Sydney, Australia
http://www.artgallery.nsw.gov.au


More information about the use-livecode mailing list