transport variables

do i have any chances to transport/inject variables from a script to an (applescript) application?
the load command works only between scripts.
-maybe another impossible question- :smiley:

The load command works for getting and setting variables of a script from an application. To get or set a variable (property or global) contained by an application then use

tell app “theapp”
set its thevar to “hello”
set avar to its thevar
end tell

I’m not able to do what thewaytoapplescript suggests. I keep getting errors. However you can do it by calling subroutines. Here’s an example. Create this applescript application and make it a stay-open application.

property theVar : missing value

on getTheVar()
	return theVar
end getTheVar

on setTheVar(someValue)
	set theVar to someValue
end setTheVar

Basically you can see I created a “getter” and “setter” subroutine for the variable. Now try this script to “set” and “get” the variable. You can see I called the stay-open applescript application “TestApp”.

tell application "TestApp"
	setTheVar("testing the var")
	set myValue to getTheVar()
end tell

return myValue

So with a stay open applescript application you can use getters and setters to handle properties, but this also shows how you can call any subroutine in a stay-open applescript application. Essentially you would create a property for any variable, then you set it as I showed, then you would have another subroutine to act on the variable which can be called from your applescript as I showed with the “getter”.