Hi all, I'm a little late to this thread in an attempt to get some scripts working in Lion. Thanks for the help. I noticed the way you set your globals, and the way you're having variables get passed on to recompiled scripts.
I take a different approach, by writing my Applescript as text, in quotation marks, and then relying on fields getting filled in when the Applescript Editor is run, and the new script has the correct data. I make one text entry called "QT_multiliner" and fill in variables using quotation marks and ampersands.
THIS FIRST SCRIPT is used to take variables given to it by a database, and generate a custom applescript for any given record in the database.
----------------------------------------------------
set yyyymmdd to (((year of (current date)) * 10000) + ((month of (current date)) * 100) + (day of (current date))) as text
set mmdd to (text items 5 through 8 of (yyyymmdd)) as text
set qtPath to "/path/to/folder/" & mmdd & "/"
set RenderPrefix to "filename_of_choice"
set TGA_path to "/path/to/folder_with_files/" & mmdd & "/" & RenderPrefix & "/" as text
set appletPath to "/path/to/folder/applet_name_" & RenderPrefix & ".app"
set temp_doc to POSIX fileappletPath
--write the applet in Script Editor. Variables will be filled in and compiled in Script Editor.
set QT_multiliner to "tell application \"Finder\"
set thePath to \"" & TGA_path & "\" as string
activate
make new Finder window
set target of Finder window 1 to (POSIX file thePath)
set theSequence to get first file of the front window as alias
close window 1
end tell
set sequenceName to \"" & RenderPrefix & ".mov\"
tell application id \"com.apple.quicktimeplayer\"
activate
open image sequence theSequence frames per second 23.98
set savePath to \"" & qtPath & "/\" & sequenceName
tell movie 1
with timeout of 2400 seconds
export to (POSIX file savePath) as QuickTime movie using settings alias \"path:to:settings:file\"
end timeout
close saving no
end tell
quit
end tell"
-- Write the script to its own applet
tell application id "com.apple.ScriptEditor2"
set x to makenewdocument
set x to the front document
set the text of document 1 to QT_multiliner
compiledocument 1
save document 1 as "application" in (temp_doc)
quit
end tell
------------------------------------------------################################ ######
...now, when that is run, the following applescript is generated with all of the variables filled in.
------------------------------------------------################################ ######
--This applet was saved by the previous script, and is saved as /path/to/folder/applet_name_filename_of_choice.app
tell application "Finder"
set thePath to "/path/to/folder_with_files/0112/filename_of_choice/" as string
activate
makenewFinder window
set target of Finder window 1 to (POSIX file thePath)
set theSequence to get first file of the front window as alias
closewindow 1
end tell
set sequenceName to "filename_of_choice.mov"
tell application id "com.apple.quicktimeplayer"
activate
open image sequencetheSequenceframes per second 23.98
set savePath to "/path/to/folder/0112//" & sequenceName
tell document 1
with timeout of 2400 seconds
export to (POSIX file savePath) as QuickTime movie using settings alias "path:to:settings:file"
end timeout
closesavingno
end tell
quit
end tell
-------------------------------------------------------
I really liked Camelot's "script / end script" function, it's better, but I just couldn't get it to pipe variables through from one script to another. Since I need to run this script on any one of dozens of computers, I need the variables to be compiled and saved within each applet.
all the best,
Vic