Highlighted

DispatchScriptRunner return JavaScript values

Explorer ,
May 25, 2020

Copy link to clipboard

Copied

Hi,

I am using DispatchScriptRunner to call some jsx code. I would like the jsx code to return a value to my C plugin. While opening the InDesign it shows an error message as no such file exist in the path.Whether I should modifies this code. Please guide me.
    do {

        ScriptRecordData arg;
        ScriptData script;
        IDFile f(PMString("Desktop:sample script.jsx"));
        script.SetFile(f);
        ScriptData result;
        PMString errorString;
        InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMgrBoss));
        InterfacePtr<IScriptRunner> scriptRunner(scriptManager, UseDefaultIID());
        Utils<IScriptUtils>()->DispatchScriptRunner(scriptRunner, script,arg, result,errorString, kTrue);
        PMString retval;
        result.GetPMString(retval);
        CAlert::InformationAlert(retval);
    } while (false);

 

 

 

Nithu_S_0-1590471533613.png

 

Nithu
Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Paths are platform dependent, the code snippet that you copied was written for a MAC and hence used a HFS path notation, even then you messed the path while editing it. HFS path starts with Macintosh HD: but you have removed all that so this is never gonna fly.

 

If you have to run this code on WIN the path changes as per WIN conventions. Atleast read the sdk documentation.

 

-Manan

TOPICS
Scripting, SDK

Views

681

Likes

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

DispatchScriptRunner return JavaScript values

Explorer ,
May 25, 2020

Copy link to clipboard

Copied

Hi,

I am using DispatchScriptRunner to call some jsx code. I would like the jsx code to return a value to my C plugin. While opening the InDesign it shows an error message as no such file exist in the path.Whether I should modifies this code. Please guide me.
    do {

        ScriptRecordData arg;
        ScriptData script;
        IDFile f(PMString("Desktop:sample script.jsx"));
        script.SetFile(f);
        ScriptData result;
        PMString errorString;
        InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMgrBoss));
        InterfacePtr<IScriptRunner> scriptRunner(scriptManager, UseDefaultIID());
        Utils<IScriptUtils>()->DispatchScriptRunner(scriptRunner, script,arg, result,errorString, kTrue);
        PMString retval;
        result.GetPMString(retval);
        CAlert::InformationAlert(retval);
    } while (false);

 

 

 

Nithu_S_0-1590471533613.png

 

Nithu
Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Paths are platform dependent, the code snippet that you copied was written for a MAC and hence used a HFS path notation, even then you messed the path while editing it. HFS path starts with Macintosh HD: but you have removed all that so this is never gonna fly.

 

If you have to run this code on WIN the path changes as per WIN conventions. Atleast read the sdk documentation.

 

-Manan

TOPICS
Scripting, SDK

Views

682

Likes

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
May 25, 2020 0
Most Valuable Participant ,
May 25, 2020

Copy link to clipboard

Copied

Well, where is the script (jsx) file exactly? 

Likes

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
Reply
Loading...
May 25, 2020 0
Explorer ,
May 26, 2020

Copy link to clipboard

Copied

I have placed the jsx file in the desktop and hereby I'll attach the exact location (C:\Users\Nithu Sathish\Desktop)

Nithu

Likes

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
Reply
Loading...
May 26, 2020 0
Explorer ,
May 28, 2020

Copy link to clipboard

Copied

I have called the JavaScript using dispatcher in Windows.And thanks for the response to call the script files.

IDFile f(PMString("C:\\Users\\Nithu Sathish\\Desktop\\sample_script.jsx"));

Nithu

Likes

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
Reply
Loading...
May 28, 2020 0
Adobe Community Professional ,
May 26, 2020

Copy link to clipboard

Copied

Paths are platform dependent, the code snippet that you copied was written for a MAC and hence used a HFS path notation, even then you messed the path while editing it. HFS path starts with Macintosh HD: but you have removed all that so this is never gonna fly.

 

If you have to run this code on WIN the path changes as per WIN conventions. Atleast read the sdk documentation.

 

-Manan

Likes

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
Reply
Loading...
May 26, 2020 3
New Here ,
Nov 05, 2020

Copy link to clipboard

Copied

Hello

 

I am a beginner to develop plugin in indesign.

I need to pass a result from JSX code to C++ plugin code.

 

I know jsx but i don't know what write in jsx to pass te result.

Can you give me an example of javascript code that return a result to C++ please ?

 

Thanks

Paulo

Likes

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
Reply
Loading...
Nov 05, 2020 0
Adobe Community Professional ,
Nov 06, 2020

Copy link to clipboard

Copied

Hi Paulo,

There is nothing special to write on the jsx end, you need to return the value as you normally do. Handling the return value has to be done on the C++ plugin end. I have written a sample snippet of C++ code for getting the string return value from jsx in the following post, have a look at it

https://community.adobe.com/t5/indesign/dispatchscriptrunner-return-values/td-p/10898739?page=1

-Manan

Likes

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
Reply
Loading...
Nov 06, 2020 0