Re: Comprehensive Applescript Reference Book (Re: Applescript equivalent of $0 in shell script)
Re: Comprehensive Applescript Reference Book (Re: Applescript equivalent of $0 in shell script)
- Subject: Re: Comprehensive Applescript Reference Book (Re: Applescript equivalent of $0 in shell script)
- From: Philip Aker <email@hidden>
- Date: Wed, 18 Oct 2006 05:39:26 -0700
On 2006-10-16, at 10:00:13, Bruce Robertson wrote:
There are other scripting facilities too. Tcl scripting language
<x-man-page://tclsh> has AppleScript support
Hi Bruce,
I see the man page but don't see an explicit reference to how TCL
supports applescript.
Sorry, I forgot it never had a man page because it started on MacOS 7
not unix. The documentation for it is actually in the Developer install:
/Developer/ADC Reference Library/documentation/DeveloperTools/Tcl/
Tclapplescript/TclAppleScript.html
Care to briefly elaborate?
Tclapplescript has more options (like for compiling and saving, etc.)
but the 'execute' call is the workhorse of dynamic scripting. If you
save the following as a file with execute permissions, then you can
run it just like any other tool from the command line without having
to use tclsh. If you want to use tclsh, then you can (optionally)
leave off the first three lines. The script illustrated is "hard-
quoted" script. If you need to pass variables into a script, then you
can build it up with the 'append' command. All Tcl commands that have
man pages use the 'n' prefix -- "man n append", "man n file", etc.
#!/bin/sh
# tclsh ignores the next line because comments are continued with a
backslash \
exec tclsh "$0" "$@"
package require Tclapplescript
AppleScript execute {
tell application "Finder"
activate
display dialog "Wins the Lottery!" with icon note
end tell
}
PS: Watch it if you clip this from Apple Mail, sometimes spurious
characters not good for shell scripts creep in depending on encoding
factors. You should be able to get rid of them by using the 'nano'
editor.
Philip Aker
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden