hunt Posted February 24, 2009 Share Posted February 24, 2009 Hello all. I can't to solve problem with assigning values to 2-dimensional arrays. Dim $List1[10][10] Dim $List2[10][10] Dim $List3[10][10] Dim $List4[10][10] ... $n=10 For $i=1 to $n "$List" & $i & "[0][0]"=10 ;????????????? Next Link to comment Share on other sites More sharing options...
Andreik Posted February 24, 2009 Share Posted February 24, 2009 Hello all. I can't to solve problem with assigning values to 2-dimensional arrays. Dim $List1[10][10] Dim $List2[10][10] Dim $List3[10][10] Dim $List4[10][10] ... $n=10 For $i=1 to $n "$List" & $i & "[0][0]"=10 ;????????????? NextIf you don't say what you want to do... I think that you want this For $INDEX = 0 To 9 Dim $LIST[$INDEX][10][10] Next For $I = 0 To 9 $LIST[$I][0][0] = "10" Next When the words fail... music speaks. Link to comment Share on other sites More sharing options...
hunt Posted February 24, 2009 Author Share Posted February 24, 2009 Need to set value in array. Variable (array) is presented as string. For $i=1 to $n Execute("$List" & $i & "[0][0]"=10);??? But this don't work Next Link to comment Share on other sites More sharing options...
SpookMeister Posted February 24, 2009 Share Posted February 24, 2009 (edited) I think he may want to look at Assign() in the help file [edit] Nevermind.. assign does not work with arrays Edited February 24, 2009 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
hunt Posted February 24, 2009 Author Share Posted February 24, 2009 No way? Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 24, 2009 Share Posted February 24, 2009 (edited) Hello all. I can't to solve problem with assigning values to 2-dimensional arrays. Dim $List1[10][10] Dim $List2[10][10] Dim $List3[10][10] Dim $List4[10][10] ... $n=10 For $i=1 to $n "$List" & $i & "[0][0]"=10 ;????????????? Next AutoIt has functions to work variable names specified by variable strings: Assign() and Eval() But they don't work with array syntax. They will work with an array variable, but only where the entire variable is being used, not where any indexes must be supplied. This demo uses Assign() to create five array variables. The array properties cannot be applied with Assign(), but come from the returned array provided by _ArrayDataGen(). Where the array must be used ByRef, as in _ArrayDisplay(), it must first be copied to a statically named temp variable: #include <Array.au3> Global $iData = 0, $avArray For $n = 1 To 5 Assign("Var" & $n, _ArrayDataGen(), 2) Next Func _ArrayDataGen() Local $avTemp[5][5] For $r = 0 To 4 For $c = 0 To 4 $avTemp[$r][$c] = $iData $iData += 1 Next Next Return $avTemp EndFunc For $n = 1 To 5 $avArray = Eval("Var" & $n) _ArrayDisplay($avArray, "$Var" & $n) Next Needless to say, there can only be very rare and esoteric reasons to put this kind of complexity in your scripts. You are probably missing an easier path. Besides... Assign/Eval are evil! P.S. On the assumption that you want the row count in [0][0], this might do about what you want, anyway: #include <Array.au3> $n=10; number of rows to declare Dim $List1[$n + 1][10] = [[$n]]; Sets count in [0][0] to $n Dim $List2[$n + 1][10] = [[$n]] Dim $List3[$n + 1][10] = [[$n]] Dim $List4[$n + 1][10] = [[$n]] _ArrayDisplay($List1, "$List1") Edited February 24, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
hunt Posted February 24, 2009 Author Share Posted February 24, 2009 PsaltyDSThanks for example. I tried it later so i dont' know as to apply this example for my script. Link to comment Share on other sites More sharing options...
weaponx Posted February 24, 2009 Share Posted February 24, 2009 Forget Assign, Eval, and Execute. Andreik's example is the best. Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 24, 2009 Share Posted February 24, 2009 PsaltyDS Thanks for example. I tried it later so i dont' know as to apply this example for my script. What are you trying to do? The Assign/Eval code I posted was for academic interest. If you just want the count in [0][0], then use the code I posted in the P.S. Andreik showed how to put your data into a single 3D array. You can also nest arrays (put an entire array in as a single element in another array). What works best depends on what you need to do, so what are you trying to do? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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