Manipulating PLAIN text on the clipboard
JonathanC at ag.nsw.gov.au
JonathanC at ag.nsw.gov.au
Thu Mar 11 00:00:33 EST 2004
On 08-Mar-04 6:38 PM, I wrote:
> 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
> ...
To which J. Landman Gay <jacque at hyperactivesw.com> replied:
> Looks like there may be a bug in the wrap function that causes it to go
> into an infinite loop, at least in some cases. It can get stuck at
> "delete word 1 to wordCount-1 of para". So maybe what is happening is
> that the repeat loop is going around in circles while you are pasting
> into another app, and what you paste is actually the original copied
> text rather than the modified text.
Thanks for pointing out the potential error in my wrap function. However,
I'm sure that's not the cause of the problem:
1. If I copy some continuous text in 10pt Verdana (in Word), switch to
Rev, click a button with the mouseUp handler above, switch back to Word
and paste, I get SUCCESSFULLY WRAPPED text, in 11pt Lucida Grande.
2. Exactly the same thing happens with similar buttons that call different
functions (changeCase, unwrap, emailQuote).
> BTW, there is an example of a word-wrap script in the Cookbook in the
> Help docs.
Thanks - definitely more robust than mine. I used it instead (and changed
"wrap(...)" to "wordWrapped(...)"in my button script) but it made no
difference. :-(
Oh well.
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