copying files
Ken Ray
kray at sonsothunder.com
Tue Feb 4 13:31:01 EST 2003
JR,
To call AppleScripts from MC, you basically put together the script that way
it should look in Script Editor, and then send it as a string using the "do"
command. Here's a simple example that activates the Finder:
on ActivateFinder
put "tell application " & quote & "Finder" & quote & cr & \
"activate" & cr & "end tell" into tScript
do tScript as AppleScript
end ActivateFinder
Results coming back from AppleScript (for example if you do a "get" in the
Script Editor it results show up in the Result Window of the Script Editor)
you can get back by checking "the result" of the "do" command. For example,
this script "gets" the word "Hello" and you can see it in MC:
on ActivateFinder
put "tell application " & quote & "Finder" & quote & cr & \
"get" && quote & "Hello" & quote & cr & "end tell" into tScript
do tScript as AppleScript
answer the result -- answers "Hello"
end ActivateFinder
As far as paths are concerned, the answer is "yes", you should convert "/"
delimited paths to ":" ones for AppleScript to be able to use them.
Additionally, you'll need to add the name of the hard drive to the path, so
if your "/"-delimited path was:
/Users/kenray/applications/MyApp.app
and the name of your HD was "Hard Drive", you'd need to convert it to:
Hard Drive:Users:kenray:applications:MyApp.app
To get the name of the hard disk, you can get (line 1 of the drives).
Hope this helps,
Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
----- Original Message -----
From: "RCS" <rcs at rcsprogramming.com>
To: <metacard at lists.runrev.com>
Sent: Tuesday, February 04, 2003 11:56 AM
Subject: copying files
> I have looked everywhere!
>
> Could somebody PLEASE tell me how to copy a file using Applescript in
> MetaCard? An example unsing shell would be much appreciated too...it does
> not have to be extensive (I am doing error checking before and after the
> actual copy). I just need to use something other than the built in copy
> routines in Metacard.
>
> It is very frustrating to not have any reference in MetaCard on how to
> integrate these external scritping capabilities. There are too many
> unanswered questions to NOT have something...for instance:
>
> HOW do I integrate Applescript?! Do I use the exact same structure as the
> Applescript editor? I did notice ONE brief mention in the MetaCard
reference
> about using the 'do' command with other languages...that's IT!
>
> I am getting the impression that I need to replace the "/" delimiter for
> files with ":". Do I also replace the "/" at the beginning of file
> references that MetaCard uses with the ":"?
>
> Is there a 'result' for any errors that AppleScript encounters?
>
>
> Sorry for my frustration, but I have been to quite a few Applescript web
> sites last nite and this morning to no avail. The AppleScript Language
Guide
> from Apple's site (and the Internet) seems to be gone, so I have NO
> reference...
>
> Thank you,
> JR
>
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
>
More information about the metacard
mailing list