rsmcdowell Posted October 7, 2004 Share Posted October 7, 2004 So i'm workin on making arrays an integral part of my script. I have tons of pixel sums stored as variables, and a description afterward of what the pixel sum is of and was wondering how i can make it more fluid looking. currently this is what it looks like Dim $variablename [2]; $variablename[0] = 2533393325; $variablename[1] = "Description goes here"; is there any way to make that less than 3 lines? also, i store x and y values for mouse clicks....stored in much the same way, anyway of making it so that it knows your passing an array to the assignment? in perl, you can pass an array as ( 283, 382 )... 283 being the first element, and 382 being the second element. any clues? Thanks in advance Link to comment Share on other sites More sharing options...
rsmcdowell Posted October 7, 2004 Author Share Posted October 7, 2004 hmm evidentally can't assign single dimensional arrays to multidimensional arrays? Dim $varname [8][2]; Dim $othervar [2]; $othervar[0] = "blah blah"; $othervar[1] = "blah blah blah"; $varname[0] = $othervar; this doesn't work? anyway of making it work? Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted October 7, 2004 Share Posted October 7, 2004 hmm evidentally can't assign single dimensional arrays to multidimensional arrays?Dim $varname [8][2];Dim $othervar [2];$othervar[0] = "blah blah";$othervar[1] = "blah blah blah";$varname[0] = $othervar;this doesn't work? anyway of making it work?<{POST_SNAPBACK}>The code posted does not do what you say it does... $varname[0] = $othervar is not setting the $varname array equal to $othervar this is setting the 0 element of the $varname array equal to the entire other array. That is not logically sound. Other than lack of logic, I do not know the answer to your question. I have not found any documentation that says you can set one array = to another so I assume it cannot be done. As such I expect you have to loop through the arrays and copy your elements manually.*** Matt @ MPCS Link to comment Share on other sites More sharing options...
scriptkitty Posted October 7, 2004 Share Posted October 7, 2004 first thing, single line kinda possible: $variablename=StringSplit("2533393325|Description goes here","|") MsgBox(1,$variablename[1],$variablename[2]) Dim $varname [8][2]; Dim $othervar [2]; $othervar[0] = "blah blah"; $othervar[1] = "blah blah blah"; for $i=0 to 1 $varname[0][$i] = $othervar[$i]; copies data from first part of first array next you could use ubound if you like to find dementions. you can copy a full array to anouther however. $variablename=StringSplit("2533393325|Description goes here","|") $output=$variablename MsgBox(1,$output[1],$output[2]) AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
rsmcdowell Posted October 7, 2004 Author Share Posted October 7, 2004 Dim $varname [8][2]; Dim $othervar [2]; $othervar[0] = "blah blah"; $othervar[1] = "blah blah blah"; $varname[0] = $othervar; i just said you can't assign single dimensional arrays to multidimensional ones, with this as an example. what i wanted as a result: "blah blah" stored in $varname[0][0] and "blah blah blah" stored in $varname[0][1] which would work in most languages....and thus my confusion. Link to comment Share on other sites More sharing options...
rsmcdowell Posted October 7, 2004 Author Share Posted October 7, 2004 (edited) NICE! atleast this gets me on the right track now, for my X and Y coordinates problem.... ;------------------------------ ; Normal Inventory Coords ;------------------------------ $invcoords[0][0] = 27; $invcoords[0][1] = 60; $invcoords[1][0] = 27; $invcoords[1][1] = 78; $invcoords[2][0] = 27; $invcoords[2][1] = 96; $invcoords[3][0] = 27; $invcoords[3][1] = 114; $invcoords[4][0] = 27; $invcoords[4][1] = 132; $invcoords[5][0] = 27; $invcoords[5][1] = 150; $invcoords[6][0] = 27; $invcoords[6][1] = 168; $invcoords[7][0] = 27; $invcoords[7][1] = 186; $invcoords[8][0] = 27; $invcoords[8][1] = 204; $invcoords[9][0] = 27; $invcoords[9][1] = 222; there's what i have....x and y positioning for inventory coordinates... since i already found that autoit has problems assigning arrays to be part of another array, i'm assuming i can't do: ;------------------------------ ; Normal Inventory Coords ;------------------------------ $invcoords[0] = StringSplit("27|60","|"); $invcoords[1] = StringSplit("27|78","|"); $invcoords[2] = StringSplit("27|96","|"); $invcoords[3] = StringSplit("27|114","|"); $invcoords[4] = StringSplit("27|132","|"); $invcoords[5] = StringSplit("27|150","|"); $invcoords[6] = StringSplit("27|168","|"); $invcoords[7] = StringSplit("27|186","|"); $invcoords[8] = StringSplit("27|204","|"); $invcoords[9] = StringSplit("27|222","|"); which makes me sad. Edited October 7, 2004 by rsmcdowell Link to comment Share on other sites More sharing options...
SlimShady Posted October 7, 2004 Share Posted October 7, 2004 I don't know exactly what you want, but I'm going to try to help. The following means: define a new array with the name $othervar. The size: one dimension with 2 elements. Dim $othervar[2] You can assign values (numbers or strings) to the 2 elements: $othervar[0] = "some value" $othervar[1] = 250 You can make an exact copy of an array. The copy can have the name you wish. Example: Dim $othervar [2] $othervar[0] = "blah blah" $othervar[1] = "blah blah blah" $NewArr = $othervar One last thing I understood. You have a multi-dimension array and you want a new array that contains one dimension of the existing array. Let me see if I can help you with that... Done. Dim $varname [8][2] Dim $othervar[8] $Dimens = 0;Which dimension? 0 or 1? For $i = 0 To 7 $othervar[$i] = $varname [$i][$Dimens] Next Link to comment Share on other sites More sharing options...
rsmcdowell Posted October 7, 2004 Author Share Posted October 7, 2004 One last thing I understood.You have a multi-dimension array and you want a new array that contains one dimension of the existing array.Let me see if I can help you with that...Done.Dim $varname [8][2] Dim $othervar[8] $Dimens = 0;Which dimension? 0 or 1? For $i = 0 To 7 $othervar[$i] = $varname [$i][$Dimens] Next<{POST_SNAPBACK}>i pretty much determined that i have to do it the long way, but with a function to hide most of the dirtiness. I'll post the function when i'm done Link to comment Share on other sites More sharing options...
scriptkitty Posted October 7, 2004 Share Posted October 7, 2004 you can enter code pairs in a few different ways. Dim $invcoords[10][2] $coords=StringSplit("27,60|27,78|27,96|27,114|27,132|27,150|27,168|27,186|27,204|27,222","|") For $i=0 To 9 $data=StringSplit($coords[$i+1],","); I use $i+1 because $coords[0] is the number of elements in the array. $invcoords[$i][0]=$data[1] $invcoords[$i][1]=$data[2] Next MsgBox(1,$invcoords[9][1],$invcoords[4][1]) AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
JSThePatriot Posted October 7, 2004 Share Posted October 7, 2004 (edited) I also read something yesterday that you can copy array's, using something along the lines of ReDim, let me check some more on it.JSEdit:Here is the documentation on ReDimThe ReDim keyword is similar to Dim, except that ReDim preserves the values in the array instead of removing the values while resizing an array. The number of dimensions must remain the same, or the old array will be forgotten during the ReDim. The array will retain the scope (Global or Local) that it had prior to resizing.I am not at all sure what you are wanting done other than cleaning up your code... You could possibly have a text file with the different items in there in a single line and do the stringsplit() as was suggested above. That would clean your script up alot.JS Edited October 7, 2004 by JSThePatriot AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 8, 2004 Share Posted October 8, 2004 Diablo II bot eh? 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