Re: Trying to script the creation of a script
Re: Trying to script the creation of a script
- Subject: Re: Trying to script the creation of a script
- From: Andrew Oliver <email@hidden>
- Date: Sun, 22 Feb 2004 16:09:02 -0800
Your problem is simply one of quotes.
In your script, you include 'thename" as part of the string object x.
However, you want to insert the current value of the name instead.
Just replace:
tell application \"Finder\" of machine \"eppc://192.168.1.100\"
open file\" & thename & \"of folder \"TitleTrack Jukebox v2.0\" of
with
tell application \"Finder\" of machine \"eppc://192.168.1.100\"
open file\" & " & thename & "\"of folder \"TitleTrack Jukebox v2.0\" of
(note the extra quotes around thename).
However, I think there may be a simpler way of doing this anyway, without
needing to launch the script editor.
The following (untested) example contains an embedded script object within
the main script. The 'open' handler makes a copy (in memory) of this script
object and uses a property within the embedded script to hold the relevant
file name. It then uses the standard 'store script' command to save the
embedded script with the relevant file name to a file you specify.
This has several advantages, not least of which is the elimination of the
need to use Script Editor, plus the compiling of the embedded script which
will avoid syntax errors, etc.
script embeddedScript
property filename : ""
tell application "2.0TitleTrack Jukebox" of machine
"eppc://192.168.1.100"
Stop
Clear
end tell
--
tell application "Finder" of machine "eppc://192.168.1.100"
open file filename of folder "TitleTrack Jukebox v2.0" of startup disk
end tell
--
tell application "2.0TitleTrack Jukebox" of machine
"eppc://192.168.1.100"
activate -- are you sure you need to activate the app?
Set Loop true
Play
end tell
end script
on open theFile
tell application "Finder"
set y to theFile as alias
set thename to the name of y
end tell
copy embeddedScript to newScript
set filename of newscript to thename
store script newScript in file "path:to:new:file"
end open
On 2/22/04 3:26 PM, "Christian Boyce" <email@hidden> wrote:
>
I'm trying to make a droplet script that makes another script. The
>
second script would be customized, based on the name of the file
>
dropped. I've gotten as far as creating the new Script Editor document
>
automatically, with text as desired, but I haven't figured out how to
>
pass the name of the dropped file to the new script.
>
>
Here's what I have:
>
>
on open thefile
>
tell application "Finder"
>
set y to thefile as alias
>
set thename to the name of y
>
end tell
>
>
tell application "Script Editor"
>
activate
>
--this is where we create the text that makes up the script.
>
--it is also where the problem lies.
>
set x to "tell application \"2.0TitleTrack Jukebox\" of machine
>
\"eppc://192.168.1.100\"
>
Stop
>
Clear
>
end tell
>
--
>
tell application \"Finder\" of machine \"eppc://192.168.1.100\"
>
open file\" & thename & \"of folder \"TitleTrack Jukebox v2.0\" of
>
startup disk
>
end tell
>
--
>
tell application \"2.0TitleTrack Jukebox\" of machine
>
\"eppc://192.168.1.100\"
>
activate
>
Set Loop true
>
Play
>
end tell"
>
--now we make the script
>
make new document with properties {text:x}
>
end tell
>
end open
>
>
>
What happens is I create a script that's absolutely perfect, except
>
that the variable "thename" is shown as "thename" and not as what
>
"thename" actually stands for. That is, I want the value of "thename"
>
to be shown in the script, not literally "thename."
>
>
In the end of course I'll want to save the script, also using the
>
"thename" variable's contents, so if anyone can help with that I'd
>
appreciate it too. Thanks.
>
>
(The point here is I am using TitleTrack Jukebox to play CDs, and I
>
want to create scripts that trigger playlists. The playlists are named
>
files, so I want scripts that open those playlists and play them. I
>
will eventually add those playlist scripts to Drag Thing tiles. And,
>
I'll make the whole thing a folder action, so when I add a playlist to
>
a folder, a new tile will show up in Drag Thing. That's the plan.)
>
>
>
--
>
Christian Boyce
>
http://www.christianboyce.com
>
_______________________________________________
>
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.
_______________________________________________
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.