Accessing another script's property variable

I have one script that gets data and assigns it to a property variable. Is there a way for another script to access the property variable from the first script?

Are you talking about two different script files?

Hi.

The answer is yes, but how you do it depends on the circumstances.

If the data-getting script is sitting there on disk with its property set to the latest value, the load script command is what you want:

set theDataScript to (load script file "path:to:My Data Script.scpt") -- Substitute the real path here .
set myData to theDataScript's dataProperty -- . and the actual name of the property.

There’s a bug in versions of Tiger up to 10.4.6 (I think) whereby if a script with properties is run from Script Menu, the values of the properties aren’t saved back to the file after a run. This has been fixed in 10.4.7. Remember too (if this bug doesn’t apply) that if the current script’s own variable ‘theDataScript’ is a property, global, or top-level variable, the whole of the data script will be saved back into the current script’s file as a value. So if the data script’s very large, you may need to declare the current script’s variable as a local, or explicitly set it to something small (like “”) before the script terminates.

The data script can also be run within the current one:

set theDataScript to (load script file "path:to:My Data Script.scpt")
run theDataScript
set myData to theDataScript's dataProperty

If the data script’s running as a stay-open application, the property in the file won’t be updated until it quits. But in that case, you can query the running application itself:

tell application "My Data Script"
	set myData to its dataProperty
end tell