mary Posted January 25, 2007 Share Posted January 25, 2007 (edited) Hi! Trying to convert a javascript array to an autoit array, I found that javascript and autoit use the same syntaxe to get elements. here an exemple ------javascript_file.JS--------------------------------- Function Js_Func(arg1, arg2, arg3) { { return Js_Func.arguments; // this return all arguments in an array } Js_Func(15, "text with coma , be carfull!" , null) ; ------javascript_file.JS--------------------------------- Now if you try to execute this js code with com ( obj "ScriptControl"), like this $jsfile="javascript_file.JS" $code = fileread($jsfile, filegetsize($jsfile)) $js = ObjCreate("ScriptControl") $js.language = "Jscript" $javascript_array = $js.Eval($code) $js = "" consoleWrite($javascript_array[1]) ; ===> here i get error consoleWrite($javascript_array.item(1) ); === here i get error some thing like "...the request property is failed..." please help thinks a lot Edited January 25, 2007 by mary Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 27, 2007 Share Posted January 27, 2007 I haven't got a clue what you were trying to do with that code. If you Eval something, it reads the string and finds the variable that is named in the string. I don't know anything about the ScriptControl object, but I can see you are using Eval wrong. Link to comment Share on other sites More sharing options...
mary Posted January 27, 2007 Author Share Posted January 27, 2007 $Js.Eval($code) ? here a call a javascript Eval function and not autoit eval ! anyway, there is a lot confusing when you use an other language witch is similar syntaxe with autoit. For exemple: With autoit . MyArray[1] ;===> return the first item of MyArray = It is the same with javascript !!! so when you get an array object from autoit you may have error when you call Myarray[1] excuse my poor english Link to comment Share on other sites More sharing options...
DaleHohm Posted January 27, 2007 Share Posted January 27, 2007 Not sure how to pass an array as a construct back to AutoIt, so you can certainly do something like this: $js = ObjCreate("ScriptControl") $js.language = "Jscript" $js.Eval("var myArray = new Array(1, 2, 3);") Local $myArray[3] $myArray[0] = $js.Eval("myArray[0];") $myArray[1] = $js.Eval("myArray[1];") $myArray[2] = $js.Eval("myArray[2];") Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
DaleHohm Posted January 27, 2007 Share Posted January 27, 2007 A Javascript Array is actually an object and $x = $js.Eval("myArray;") Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
mary Posted January 28, 2007 Author Share Posted January 28, 2007 Thinks a lot Dale !! (Frensh kiss !) Link to comment Share on other sites More sharing options...
ozmike Posted October 12, 2013 Share Posted October 12, 2013 (edited) Hi A more OO alternative to Full javascript arrays in auto it see this post '?do=embed' frameborder='0' data-embedContent>> $myArray[0] = $js.Eval("myArray[0];") add a item(n) method to the js array object Add this to your web page Array.prototype.item =function( i ) { return this } ; ConsoleWrite("$myArray[0] = " & $myArray.item(0) & @CR) ; a way to access the array YES! and Edited December 23, 2013 by ozmike Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now