Passing Data from one script to another?

… would be not to use the run handler at all. For this sort of task, I think it’s more sensible to leave the run handler to do what it’s best at: handling the run event sent by the applet shell. Instead, create a new handler to perform the task you need:

on doSomething(var, var2)
   display dialog var & var2
end doSomething

on run
   display dialog "Hey! Don't run me directly." giving up after 5
end run

And then run the following code in your Script Editor:

tell application "Mac OS X:Users:cpalma:Desktop:test"
    launch
    ignoring application responses
        doSomething("Hello", "World")
    end ignoring
end tell

Simple and logical. Plus you can put as many different handlers into the script as you like.

Going a little further into it: depending on what it is you’re actually trying to do, there may be better approaches than using a script application that launches and quits every time you want to use it. Two possibilities:

  1. The “script server” approach, where you save your script applet as a stay-open application so that it’s always available and you don’t have to muck about with “launch” each time.

  2. The “library” approach, where you use the Standard Additions’ “load script” feature to ‘import’ the script you want:

set theDoSomethingModule to load script "Mac OS X:Users:cpalma:Desktop:test"

tell theDoSomethingModule to doSomething("Hello", "World")

Both are very powerful, valuable techniques. They’re also extremely easy to use (I use them all the time these days and often wonder how I ever did without).

HTH