2 Replies Latest reply on Sep 9, 2018 10:46 PM by johnp45247251

    Pass array arguments in terminal InDesignServer sampleclient

    johnp45247251 Level 1

      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.

        • 1. Re: Pass array arguments in terminal InDesignServer sampleclient
          Manan Joshi Level 4

          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

          • 2. Re: Pass array arguments in terminal InDesignServer sampleclient
            johnp45247251 Level 1

            Thank you for your valuable answer..