Skip to main content
April 13, 2011
Answered

Get a return value from app.DoScript() ?

  • April 13, 2011
  • 2 replies
  • 2975 views

Is there a way to get a value back?

This topic has been closed for replies.
Correct answer Sunil Yadav

As per my understanding for your need, you can not directly return any value, But still you can full fill your need by declaring a variable before calling another script using app.doScript and pass this variable and in another file store result in that variable and when execution of script finishes you can get that result through that variable.

Best

Sunil

2 replies

Sunil Yadav
Sunil YadavCorrect answer
Legend
July 24, 2018

As per my understanding for your need, you can not directly return any value, But still you can full fill your need by declaring a variable before calling another script using app.doScript and pass this variable and in another file store result in that variable and when execution of script finishes you can get that result through that variable.

Best

Sunil

Participating Frequently
June 27, 2023

Unfortunately, passing of variables only works for doScript calls outside any function. But at least on Mac platform, text returned from an AppleScript is forwarded by doScript, as suggested by the previous answers.

Inspiring
April 13, 2011

This works for me:

alert(app.doScript("1"));

In other words - the doScript result is the last evaluated expression, or the return value if that is a function invokation.
Dirk

Muppet_Mark-QAl63s
Inspiring
April 13, 2011

Yep same here…

var appScr = 'return \"This String…\"'; alert(app.doScript(appScr, ScriptLanguage.APPLESCRIPT_LANGUAGE));