Calling AppleScript Functions From an AppleScript File |
|
set theScript to load script (alias "MacHD:otherFile")
tell theScript to executeThat("param",123)
The only thing "AppleScriptFunction" does is produce these two lines
correctly and execute them as AppleScript.ASfunc. The strings between quotes, the numbers
without quotes.
get AppleScriptFunction("executeThat", "MacHD:otherFile", "param", 123)
and in the stack-script you put:
function AppleScriptFunction aFun, aFile
put "set theScript to load script (alias ""e&aFile"e&")"&return& \
"tell theScript to "&aFun&"(" into ASfunc
if paramcount() > 2 then
repeat with e = 3 to paramcount()
put param(e) into f
if param(e) is a number then
put f & "," after ASfunc
else
put quote & f & quote & "," after ASfunc
end if
end repeat
put ")" into last char of ASfunc
else
put ")" after ASfunc
end if
do ASfunc as applescript
end AppleScriptFunction
Originally posted 3/12/2002, updated on 8/12/2002 by Terry Vogelaar to the Use-Revolution List
(See the complete post/thread)