Skip to main content
Inspiring
September 3, 2018
Answered

Pass array arguments in terminal InDesignServer sampleclient

  • September 3, 2018
  • 1 reply
  • 985 views

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.

This topic has been closed for replies.
Correct answer Manan Joshi

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

1 reply

Manan JoshiCommunity ExpertCorrect answer
Community Expert
September 3, 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 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

-Manan
AD4003Author
Inspiring
September 10, 2018

Thank you for your valuable answer..