Re: Copy and Replacing
Re: Copy and Replacing
- Subject: Re: Copy and Replacing
- From: Kai Edwards <email@hidden>
- Date: Sat, 05 Oct 2002 22:26:17 +0000
on Sat, 05 Oct 2002 20:46:28 +1000, Shane Stanley
<email@hidden> wrote:
>
On 5/10/02 4:56 PM +1000, Paul Berkowitz, email@hidden, wrote:
>
>
>> As has noted, it is in the Finder dictionary. There was also a time
>
>> (System 7.5 I think, not sure how long it lasted) when it would act like
>
>> 'duplicate' under certain conditions. From memory, it would do so when
>
>> passed a Finder file ref, alias or FSS, but would otherwise behave in
>
>> the documented manner. Presumably done to help newbies.
>
>>
>
> It hasn't for quite some time, at least since OS 8.5 , probably since 8.1.
Can't currently check for 8.5 but (FWIW) the pseudo-duplicate behaviour of
'copy' was still there in 8.1 and 9.1, though undocumented in the Finder
dictionaries. Only the following entry appears - under "Misc Suite" in 8.1
and "Finder Basics" in 9.1:
copy: Copy the selected items to the clipboard (the Finder must be the front
application)
>
I think one of the causes of confusion was that the Finder used to *record*
>
duplicating as copying; copy would turn up instead of duplicate in the
>
recorded script.
Quite. When simply duplicating a file in 8.1 or 9.1, this is recorded:
-------------------------
tell application "Finder"
activate
select file "Test File"
duplicate selection
end tell
-------------------------
- but option-dragging a file to another location results in this:
-------------------------
tell application "Finder"
activate
select file "Test File"
copy selection to folder "Test Folder"
end tell
-------------------------
As pointed out by has, the type of copy action seems to depend on the
presence or absence of parameters.
So 'copy file x to folder y' results in a file being duplicated to the
specified location - while 'copy' (without parameters) simply copies the
text from the current Finder selection.
Interestingly, invoking the 'copy' command from the Edit menu is recorded
like this:
-------------------------
tell application "Finder"
activate
select file "Test File"
<<event aevtcopy>> selection
end tell
-------------------------
However, running the script (exactly as recorded by the Finder) errors with:
"Finder got an error: selection doesn't understand the +event aevtcopy;
message." 8-0
(If this can't be replicated on other equivalent systems, I've obviously got
a problem on at least two different test machines! For the moment,
however...)
Not surprisingly, the raw code <<event aevtcopy>> won't recompile,
suggesting that this version of 'copy' isn't in the Finder's dictionary. I'd
thought initially that it would compile to 'copy' - but the raw code for
'copy' is actually <<event misccopy>> (which *is* in the dictionary).
There's one other behaviour I found interesting, given a belief that the
'copy' command could be applied to a file reference. Unless I'm going
seriously wrong somewhere, this seems to ignore any specified target and
defaults to the Finder's selection.
In other words, the copy command below appears to accept the selection as a
target:
-------------------------
tell application "Finder"
activate
select file "Test File"
copy selection
end tell
-------------------------
Result: --> file "Test File" of application "Finder"
Clipboard: --> Test File
OK - nothing apparently strange about that. However, if 'copy selection' is
replaced by just 'copy', the same results are achieved. Furthermore, if one
tries to specify a different target...
-------------------------
tell application "Finder"
activate
copy file (choose file)
end tell
-------------------------
...the Finder continues to target, copy and return whatever was originally
selected. (If nothing is selected, an empty list is returned - and the
clipboard remains unchanged.)
Kai
--
email@hidden
email@hidden
_______________________________________________
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.