-
1. Re: [JS IDCS5] retrieve all scriptArgs
Muppet Mark-QAl63s May 18, 2011 3:22 AM (in response to stoereee)1 person found this helpfulwould this not do?
var allArgs = app.scriptArgs.getElements();
-
2. Re: [JS IDCS5] retrieve all scriptArgs
stoereee May 18, 2011 4:43 AM (in response to Muppet Mark-QAl63s)would this not do?
var allArgs = app.scriptArgs.getElements();
I tried that, but how to get the values of these?
-
3. Re: [JS IDCS5] retrieve all scriptArgs
stoereee May 18, 2011 4:47 AM (in response to stoereee)I tried:
allArgs.toString():
and
allArgs[0].toString();
Result:
[object ScriptArg]
No value
-
4. Re: [JS IDCS5] retrieve all scriptArgs
Laubender May 18, 2011 5:26 AM (in response to stoereee)stoereee,
getElements() creates and returns an array.
See details at:
http://www.indiscripts.com/post/2010/07/on-everyitem-part-2
And when you are at it part 1 is a recommended read as well.
Uwe
-
5. Re: [JS IDCS5] retrieve all scriptArgs
stoereee May 18, 2011 6:35 AM (in response to Laubender)getElements() creates and returns an array.
I was aware it is returning an array. But it's not slightly clear to me how the read the value strings of the scriptArgs-Array
-
6. Re: [JS IDCS5] retrieve all scriptArgs
stoereee May 18, 2011 7:23 AM (in response to stoereee)app.scriptArgs.getValue("Arg1") gives the value string of the passed name Arg1. When I use app.scriptArgs.getElements(), I get an array of all the passed names. How I can I get the values of these array passed names?
-
7. Re: [JS IDCS5] retrieve all scriptArgs
John Hawkinson May 18, 2011 8:37 AM (in response to stoereee)When I use app.scriptArgs.getElements(), I get an array of all the passed names.
You do?
I can't seem to make .getElements() do anything useful at all:
>> app.scriptArgs.get("alpha") beta >> app.scriptArgs.get("gamma") delta >> app.scriptArgs.getElements().constructor function Array() { [native code] } >> app.scriptArgs.getElements().length 1 >> app.scriptArgs.getElements()[0].constructor.name ScriptArg >> app.scriptArgs.getElements()[0].get("alpha") beta
That is, I just get back a singleton scriptArg member in the array that's the same as the app.scriptArgs.
-
8. Re: [JS IDCS5] retrieve all scriptArgs
stoereee May 18, 2011 9:38 AM (in response to John Hawkinson)I can't seem to make .getElements() do anything useful at all
Is there a other way of iterating through all scriptArgs passed to a server script to get all values?
-
9. Re: [JS IDCS5] retrieve all scriptArgs
John Hawkinson May 18, 2011 11:43 AM (in response to stoereee)1 person found this helpfulIs there a other way of iterating through all scriptArgs passed to a server script to get all values?
You say other as if there is a way at all -- which there does not seem to be.
Why are you using scriptArgs anyhow? Can't you use the native Javascript arguments?
In any case, you could try packing all your args into a single scriptArg. Or, you could have a scriptArg with a known value that was a list of all other scriptArgs...you do control both sides of this, right?
-
10. Re: [JS IDCS5] retrieve all scriptArgs
stoereee May 19, 2011 4:54 AM (in response to 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[i], value:myValue[i]}); 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?
-
11. Re: [JS IDCS5] retrieve all scriptArgs
John Hawkinson May 19, 2011 6:54 AM (in response to stoereee)I don't know any AS3, but your code looks a bit odd:
params.scriptArgs = new Array(); params.scriptArgs.push({name:myName[i], value:myValue[i]}); 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[i]+":"+myValue[i]));
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.
-
12. Re: [JS IDCS5] retrieve all scriptArgs
stoereee May 20, 2011 5:30 AM (in response to John Hawkinson)Thank you John, this helps a lot.
Example:
params.scriptArgs.push({name:"argsNames", value:myNaams}); params.scriptArgs.push({name:"argsValues", value:myValues});
And then:
app.scriptArgs.get("argsNames").split(":"); app.scriptArgs.get("argsValues").split(":");