accessing script files from an applescript action

im creating an automator workflow which is mostly in applescript, just taking advantage of some of the powerful built in actions for convenience, however i have hit a problem. i need at least two lists to be accessible throughout the workflow including on both sides of an action that can not pass on any such information. it seems the obvious solution is to use an external script file as a temporary memory for the script but this doesn’t seem to work.

take the following script for example.


tell application "Finder" to get name of startup disk
set thepath to result & ":tmp:tempprefs"
script myprefs
	property favcolor : {""}
end script

try
	set myprefs to load script file thepath
on error
	set item 1 of favcolor of myprefs to text returned of (display dialog "Favourite Color:" default answer "" buttons {"OK"} default button "OK")
	store script myprefs in thepath replacing yes
end try
display dialog "your favourite color is obviously " & favcolor of myprefs

it works fine in script editor but in an applescript action it won’t compile because it complains about the line that loads the script from the file with a syntax error (expecting end of file but found identifier).
i am completely stumped as to why it’s not working,
anyone got any insights? or perhaps alternative solutions?

Hello nat,
I just ran into the exact same error - in Apples Script Editor and Late Nights Script Debugger this code works perfectly:


set theLibraryPath to "Path:To:Script.scpt"
set theLibrary to load script file theLibraryPath

However, in Automator’s Run AppleScript action the above code fails. I discovered that putting it in a Finder tell works, though.


tell application "Finder"
     set theLibraryPath to "Path:To:Script.scpt"
     set theLibrary to load script file theLibraryPath
end tell

Hope someone find this useful
jON bEEBE