On 2006-10-15, at 07:44:19, Hiroshi T. wrote:
I'm not entirely clear on what you want to accomplish, but you can script application bundles easily with regular scripts:
I should have stated my intention first. That's code sharing. I wrote an Applescript to convert music file format in iTunes. There are many options for conversion and currently the script asks every option in the 'display dialog'. Some of these options are of frequent use and I want to do them by one click.
My envisioned solution to implement this mechanism is to make symbolic links to the script and call them in the 'iTunes Script Menu'. For this to work, I need '$0'-equivalent in Applescript. Namely, the script is to obtain the name of file off which it is launched and changes what it does according to the file name. For example, let the name of the script be 'Convert.scpt' and let us make symbolic links to it named 'AAC.scpt', 'DeEmph.scpt', and 'Add2iPod.scpt'. Put all of them in the directory ~/Library/iTunes/Scripts so that their file names appear in the 'iTunes Script Menu'. The script asks many options if it is launched as 'Convert' but it only de-emphasize the selected tracks if it is launched as 'DeEmph", etc.
The script must be saved as 'Script' since some of the functions in the script are called by the command 'osasubr', which can execute a function in an Applescript file from a shell script. This is necessary because 'Convert.scpt' offers 'batch option', which allows me to do batch conversion later.
Hello Hiroshi,
I see that you want to avoid those many dialog boxes. You can call subroutines in AppleScript applications from scripts. Say you make an AppleScript application bundle called "HiroConvert.app" and put in it the contents of Convert.scpt.
--- on convert(theOptions) -- Convert.scpt code here end convert
on AAC(theOptions) set tf to theOption's batch set fname to theOption's name if (tf is true) then display dialog "batch" with icon note else display dialog "NO batch" with icon stop end if convert({batch:tf, creator:"Hiro", name:fname}) end AAC
on DeEmph(theOptions) convert({batch:false}) end AAC
Then you have script in the iTunes Script menu called "AAC". It looks something like:
tell application "HiroConvert" activate AAC({batch:false}) end tell
I'm thinking the application can do all the work of your Convert.scpt and that the script then does not need to know the path. Is that true?
There are other scripting facilities too. Tcl scripting language < x-man-page://tclsh> has AppleScript support (maybe some others like Python and Perl too).
I didn't know that. I've been heavily depending on Expect/Tcl since NEXTSTEP days. Expect/Tcl is the script of my choice.
I like your choice very much.
Best wishes,
|