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

Pass array arguments in terminal InDesignServer sampleclient

Participant ,
Sep 02, 2018 Sep 02, 2018

Copy link to clipboard

Copied

Hi all,

In terminal, the below command is working

/Users/user/Desktop/IDS_Sever/sampleclient -host localhost:18384 /Users/user/Desktop/Test/t.jsx myArg="/Users/user/Desktop/Test/"

In Jsx file, to retrieve

var nw = app.scriptArgs.get("myArg");   // get the value to nw

I want to pass array as arguments and It is not working.

/Users/user/Desktop/IDS_Sever/sampleclient -host localhost:18384 /Users/user/Desktop/Test/t.jsx myArg=["/Users/user/Desktop/Test/","/Users/user/Desktop/Test/sample.xml", "1", 5758, "45454"]

In Jsx file, to retrieve

var nw = app.scriptArgs.get("myArg");

File(nw[0]).remove(); // get like this, Script result (xsd__boolean): false

Please give any helps!!

thanks,

John.

TOPICS
Scripting

Views

771

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

Community Expert , Sep 03, 2018 Sep 03, 2018

I don't have an IDS installation handy but you could try the following. Seems the argument takes only string as value, so you need to convert the argument to array before using it. You can do that using two ways mentioned below

var arg = app.scriptArgs.get("myArg");

var argAsArray = eval(arg)

For the code above you would send your argument as "[1,2,3,4]". However i would not recommend this method as this has a possibility that eval can evaluate anything that is a valid javascript and could lead to

...

Votes

Translate

Translate
Community Expert ,
Sep 03, 2018 Sep 03, 2018

Copy link to clipboard

Copied

I don't have an IDS installation handy but you could try the following. Seems the argument takes only string as value, so you need to convert the argument to array before using it. You can do that using two ways mentioned below

var arg = app.scriptArgs.get("myArg");

var argAsArray = eval(arg)

For the code above you would send your argument as "[1,2,3,4]". However i would not recommend this method as this has a possibility that eval can evaluate anything that is a valid javascript and could lead to issues if a malicious js snippet is sent in as an argument.

The second method is that you send in argument as a delimiter separated string which can then be split to obtain the array

var arg = app.scriptArgs.get("myArg");

var argAsArray = arg.split(",")  //if , is used as delimiter of the list

For the above code snippet the argument would be "1,2,3,4"

-Manan

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
Participant ,
Sep 09, 2018 Sep 09, 2018

Copy link to clipboard

Copied

LATEST

Thank you for your valuable answer..

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