FROM REV to APPLESCRIPT

Terry Vogelaar terry at discovery.nl
Fri Aug 9 23:01:01 EDT 2002


> How can I set the value of a  variable in an Applescript piece of code to a
> field of a stack in REV?
> Am I supposed to use the clipboard?

For all smooth bi-directional RunRev-AS communication you can use the
following technique:

You store the AS-functions in a separate file; a normal AppleScript-file.

Then you must know the path and the name of the function in the file. You
call it with:

get AppleScriptFunction("nameOfFunction", "path:to:file", 1, 2, "three",
"four") 
Mind that on Mac OS classic you need to use colons in the path (2nd param),
while on Mac OS X you must use slashes.

Then in the stack-script you can 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
  else
    put " " after ASfunc
  end if
  put ")" into last char of ASfunc
  do ASfunc as applescript
end AppleScriptFunction

Now you can call any function with any number of parameters. The value that
is returned by the AppleScript-function is returned by "AppleScriptFunction"
as well. So any AppleScript-variable can be sent to RunRev and vice versa
this way.

Terry





More information about the use-livecode mailing list