tagada Posted June 12, 2007 Share Posted June 12, 2007 Hi, I try to create X arrays ($array1, $array2, $array3... $arrayX) where X must be defined by users. So it may be any number. Before starting write the final script i did some tests. After many tests, i don't understand why the first code works and the second... does not... #include <Array.au3> for $n = 1 to 3 Assign ("var" & $n, _ArrayCreate("a" & $n, "b" & $n, "c" & $n, "d" & $n , "e" & $n), 2) _ArrayDisplay( Eval("var" & $n), "test" & $n) next ExitoÝ÷ Ù«¢+Ø¥¹±Õ±ÐíÉÉä¹ÔÌÐì()½ÈÀÌØí¸ôÄѼÌ()ÍÍ¥¸ ÅÕ½ÐíÙÈÅÕ½ÐìµÀìÀÌØí¸°}ÉÉå ÉÑ ÅÕ½ÐíÅÕ½ÐìµÀìÀÌØí¸°ÅÕ½ÐíÅÕ½ÐìµÀìÀÌØí¸°ÅÕ½ÐíÅÕ½ÐìµÀìÀÌØí¸°ÅÕ½ÐíÅÕ½ÐìµÀìÀÌØí¸°ÅÕ½ÐíÅÕ½ÐìµÀìÀÌØí¸¤°È¤)}ÉÉå¥ÍÁ±ä Ù° ÅÕ½ÐíÙÈÅÕ½ÐìµÀìÀÌØí¸¤°ÅÕ½ÐíÑÍÐÅÕ½ÐìµÀìÀÌØí¸¤()}ÉÉå Ù° ÅÕ½ÐíÙÈÅÕ½ÐìµÀìÀÌØí¸¤°ÅÕ½ÐíÅÕ½Ðì¤)}ÉÉå¥ÍÁ±ä Ù° ÅÕ½ÐíÙÈÅÕ½ÐìµÀìÀÌØí¸¤°ÅÕ½ÐíÑÍÐÅÕ½ÐìµÀìÀÌØí¸¤()}ÉÉå%¹ÍÉÐ Ù° ÅÕ½ÐíÙÈÅÕ½ÐìµÀìÀÌØí¸¤°È°ÅÕ½ÐíUÁÑÅÕ½Ðì¤)}ÉÉå¥ÍÁ±ä Ù° ÅÕ½ÐíÙÈÅÕ½ÐìµÀìÀÌØí¸¤°ÅÕ½ÐíÑÍÐÅÕ½ÐìµÀìÀÌØí¸¤()¹áÐ()á¥Ð Is it possible to create $array1, array2, ... without using Assign() ? Thank you for helping. TaGaDa Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 12, 2007 Share Posted June 12, 2007 Learn to use higher dimensions in the arrays. This creates a single 2D array based on the user input number. Each 'thingy' gets 5 arrays created for it (a thru e, or actually 0 thru 4). Note that the 1D array is created as $avTemp and that array is stored as an element inside $avArrays: #include <array.au3> $n = Number(InputBox("Test", "How many thingys?", "0")) Dim $avArrays[$n][5] ; 5 Subscripts for each thingy [$n][0] thru [$n][4] For $x = 0 To UBound($avArrays) - 1 For $y = 0 To UBound($avArrays, 2) - 1 Dim $avTemp[1] = [0] _ArrayAdd($avTemp, "Add x=" & $x & " y=" & $y) _ArrayAdd($avTemp, "Update x=" & $x & " y=" & $y) $avArrays[$x][$y] = $avTemp Next Next MsgBox(64, "Status", "Created " & ($n * 5) & " arrays, five each for " & $n & " thingys.") ; Display the third array for the second thingy... $avTemp = $avArrays[1][2] ; remember numbering is zero-based _ArrayDisplay($avTemp, "2nd thingy, third array") To access one of those arrays, first you copy it out of $avArrays to a temp variable. For example, the demo displays the contents of the third array of the second thingy ($c2 in your code). 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...
tagada Posted June 12, 2007 Author Share Posted June 12, 2007 I seem to understand. i did not know the UBound() function. thank you for your code I would not found this by myself. :"> Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 13, 2007 Share Posted June 13, 2007 I seem to understand. i did not know the UBound() function.thank you for your codeI would not found this by myself. :">Assume the lotus position, calm your inner self, and chant with me......arrays are our friends, arrays are our friends, arrays... 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