Get a variable from another script

In applescript, can you use a variable that was defined in another script? I think you will have something like:

set test to (load script "/tmp/a.scpt") 

But how would you choose a particular variable?

+4
source share
1 answer

You can use property variables in an external script

e.g. a.scpt:

 property foo : "hello world" 

... and in the calling script, you use the "x of n" link style.

 set test to (load script "/tmp/a.scpt") display dialog (the foo of test) 

You can also access the returned handler result in an external script.

e.g. a.scpt:

 on getChoice() set res to choose from list {"one fish", "two fish", "red fish", "blue fish"} return res end getChoice 

... and in the calling script:

 set choice to getChoice() of test 
+5
source

Source: https://habr.com/ru/post/1500258/


All Articles