This is a representation of my primary Applescript MyScript1:
property gVar1 : ""
property gVar2 : 0
on run
display dialog "Ask a question" buttons {"Cancel","OK"} default button "OK"
if button returned of result = "OK" then
gHandle1()
else
return
end if
end run
on gHandle2(LocalVar1)
if LocalVar1 = "widget1" then return gVar1
if LocalVar1 = "widget2" then
gHandle1()
return gVar2
end if
end gHandle2
on gHandle1()
gVar2 = gVar2 + 5
end gHandle1
My secondary calling script, named MyScript2, would be something like:
tell application "MyScript1" to gHandle2("widget2")
My purpose of all this is to get property data out of MyScript1 without incurring a display dialog box.
MyScript1 is an Applescript compiled application. If I double-click on the MyScript1 application, I want the display dialog to ask me what to do. If MyScript2 activates MyScript1, I do NOT want the display dialog box to appear. (It does because the run handler is running on launch; I thought if you called another handler, “on run” didn’t execute like when the “on open” handler executes. Guess I’m wrong!)
Also, MyScript2 gets an invalid connection error when trying to call MyScript1’s gHandle2 handler.
I could have sworn that you could call one Applescript’s handler from another script… It’s been a long time since I’ve written Applescript code. So, can someone tell me what I’m doing wrong or tell me how better to perform what I want?
Thank you,
Rob