Re: weird clipboard behaviour
Re: weird clipboard behaviour
- Subject: Re: weird clipboard behaviour
- From: Dave Johnson <email@hidden>
- Date: Thu, 15 Nov 2001 09:51:29 -0500
on 11/14/01 8:13 PM, Christopher Nebel at email@hidden wrote:
>
On Wednesday, November 14, 2001, at 02:44 PM, Shane Stanley wrote:
>
>
> On 15/11/01 6:12 AM +1000, Jon Pugh, email@hidden, wrote:
>
>
>
>> In the first case it might try to return styled text if that is on the
>
>> clipboard, and I wonder if that could be involved
>
>
>
> Chris N has written before of a bug in the offset command to do with
>
> styled
>
> v. non-styled text, although the details escape me. And I thought he
>
> said it
>
> had been fixed, but that might be wishful thinking.
>
>
It has been in AppleScript 1.7, as long as the styled text in question
>
is well-formed, as opposed to the weird mutant crap "the clipboard"
>
returns in some cases. The root bug is in "the clipboard" (and yes,
>
it's still Jon's code); a couple other parts of AppleScript are
>
insufficiently resilient to cope.
>
>
What happens is that if the clipboard only contains plain text (e.g.,
>
you've just said 'set the clipboard to "foo"'), "the clipboard" decides
>
that it really ought to return styled text, and tries to fabricate a
>
style record. Unfortunately, it does this in a spectacularly incorrect
>
way that causes some code downstream to believe that the string is
>
empty. In this case, it's some code that the 1.7 "offset of" relies on,
>
so you get the wrong answer.
>
>
The workaround is to strip the style info from "the clipboard"'s result
>
somehow. One way to do this is to coerce it to Unicode text (and back
>
again if you feel the need). For example, this works:
>
>
set a to "abcdefghijklmne"
>
offset of "e" in a --> 5
>
set the clipboard to a
>
set b to (the clipboard) as Unicode text
>
offset of "e" in b --> 5
>
>
>
--Chris Nebel
>
AppleScript Engineering
>
_______________________________________________
>
applescript-users mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Thanks, this clears up a lot. It's still weird, but now I think I can get
back to the task or writing out a file with UNIX line endings.
Thanks again
Dave