Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Comprehensive Applescript Reference Book (Re: Applescript equivalent of $0 in shell script)



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: http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden
References: 
 >Re: Comprehensive Applescript Reference Book (Re: Applescript equivalent of $0 in shell script) (From: Bruce Robertson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.