• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Get a return value from app.DoScript() ?

New Here ,
Apr 13, 2011 Apr 13, 2011

Copy link to clipboard

Copied

Is there a way to get a value back?

TOPICS
Scripting

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jul 23, 2018 Jul 23, 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.

Test123.JPGTest1234.JPG

Best

Sunil

Votes

Translate

Translate
Advocate ,
Apr 13, 2011 Apr 13, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 13, 2011 Apr 13, 2011

Copy link to clipboard

Copied

Yep same here…

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 23, 2018 Jul 23, 2018

Copy link to clipboard

Copied

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.

Test123.JPGTest1234.JPG

Best

Sunil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines