Skip to main content
Inspiring
May 18, 2011
Answered

[JS IDCS5] retrieve all scriptArgs

  • May 18, 2011
  • 1 reply
  • 3812 views

Hello,

Is there a way of iterating through all arguments passed to a server script (with soap) in a for-loop fashion?

So far I have been able to retrieve the argument values by using the following syntax;

var arg1 = app.scriptArgs.getValue("Argument_1");
var arg2 = app.scriptArgs.getValue("Argument_2");

But all the arguments passed to the server are dynamically build. So how could I retrieve each  argument value?

Regards, Sjoerd

This topic has been closed for replies.
Correct answer John Hawkinson
you do control both sides of this, right?

Yes, the args are set with Flex and sent with SOAP:

var ws:WebService = new WebService();
ws.loadWSDL("http://192.168.254.123:18383/service?wsdl");
ws.endpointURI = "http://192.168.254.123:18383";
ws.loadWSDL();
           
var params:Object = new Object();
params.scriptLanguage = "javascript";
params.scriptFile = scriptFilepath.text;

params.scriptArgs = new Array();
params.scriptArgs.push({name:myName, value:myValue});

ws.RunScript(params);

In any case, you could try packing all your args into a single scriptArg

How to pack all the args in one single scriptArG?


I don't know any AS3, but your code looks a bit odd:

params.scriptArgs = new Array();
params.scriptArgs.push({name:myName, value:myValue});
ws.RunScript(params);

That's not inside a loop, so you are just sending one arg? So why not use

params.scriptArgs.push({name: "arg", value:(myName+":"+myValue));

and then in ExtendScript:

var arg, myName, myValue;

arg = app.scriptArgs.get("arg").split(":");

myName=arg[0];

myValue=arg[1];

Of course this uses a literal ":" as a seperator -- if that might appear in your name or value, you'd have a problem. If so there are a hundred ways to solve it, probably the easiest way is to use the .toSource() method [how does that work in AS3?]  to bundle it all together. Similarly if you're passing an array.

1 reply

Muppet_Mark-QAl63s
Inspiring
May 18, 2011

would this not do?

var allArgs = app.scriptArgs.getElements();

stoereeeAuthor
Inspiring
May 18, 2011

would this not do?

var allArgs = app.scriptArgs.getElements();


I tried that, but how to get the values of these?

stoereeeAuthor
Inspiring
May 18, 2011

I tried:

allArgs.toString():

and

allArgs[0].toString();

Result:

[object ScriptArg]

No value