Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get variable from another script

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

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

But how would you pick a specific variable?

like image 432
Qwertie Avatar asked Mar 25 '26 04:03

Qwertie


1 Answers

You could use property variables in your external script

e.g, a.scpt:

property foo : "hello world"

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

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

You can also access the returned result of a handler in the 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
like image 91
adamh Avatar answered Mar 27 '26 16:03

adamh