Pass variable from one Applescript to another

I want to be able to:
¢ choose a file path in one script
¢ set it as a variable
¢ run another script file
¢ pass the variable to that script

So far I can only do it by using the clipboard as shown in the following very simple examples. Is there another better way?

First Script

set destPath to "Put this text in the dialog box"
set the clipboard to destPath

set myScript to load script file "/Users/dwhitehead/Desktop/test/Display_Dialog_Test.scpt" as POSIX file
run myScript

Second Script

set destPath to the clipboard
display dialog destPath

Model: 2 x 2.8 GHz Quad-Core Intel Xeon
AppleScript: 2.1.2
Browser: Firefox 3.6.14
Operating System: Mac OS X (10.6)

Hi,

Just don’t run the script, but load it instead and set its properties and call its handlers:

Called script:


property msg : missing value

on dspmsg()
	display dialog msg
end dspmsg

Calling script:


set scptobject to load script (POSIX file "/Users/martin/Desktop/test.scpt")
set scptobject's msg to "Lua rulez!"
scptobject's dspmsg() -- displays the dialog "Lua rulez!"

Best regards,

Martin

Thanks Martin that’s exactly what I was looking for.

But which path should we enter if this two scripts are parts of one applescript studio project?