Re: How does one paste in OS9.2.2
Re: How does one paste in OS9.2.2
- Subject: Re: How does one paste in OS9.2.2
- From: kai <email@hidden>
- Date: Sat, 23 Aug 2003 01:11:16 +0100
on Fri, 22 Aug 2003 18:30:02 -0400, "Marc K. Myers" wrote:
>
>> Date: Fri, 22 Aug 2003 11:55:52 -0400
>
> Subject: How does one paste in OS9.2.2
>
> From: Josef Kleine-Jaeger <email@hidden>
>
> To: <email@hidden>
>
> I am using the following code in OS9 and I works fine.
>
>
>
> tell application "Finder"
>
> set theOrder to the clipboard
>
> end tell
>
> Now I am trying to do the same in OS9.2.2 and I am getting the
>
> following
>
> error.
>
> "Finder got an error: Some data could not be read."
>
>
I'm not running 9.2.2, but this should work:
>
>
tell application "Finder" to activate
>
set theOrder to the clipboard
>
Scripting addition commands like "the clipboard" seem to work better
>
when they're not in a "tell" to an application.
Since the application running the script would normally be frontmost, that's
generally (but not necessarily always) the case. However, I'm afraid that
telling the Finder to activate first will probably only make matters worse -
and may result in a thread protocol error (-619) or similar.
The safest way (IMO) is to activate whichever app is required and then,
within the same tell block, set or get the clipboard.
If there's a chance that some user action might change the frontmost
application before a clipboard set/get command can be issued, then something
like this might help to avoid problems (all one line):
=================
tell application ((path to frontmost application) as string) to set theOrder
to the clipboard
=================
Having said all that, I try to use the clipboard only as a last resort -
since there's usually a more effective way to set the value of a variable
directly from the source application:
(pseudo-code)
-----------------
tell application "Source App" to set theValue to [selection/selected text]
tell application "Target App" to doSomethingWith theValue
-----------------
---
kai
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.