ddarek Posted February 18, 2012 Share Posted February 18, 2012 (edited) Hi I am beginner in Autoit as well as in programming Simple scripts I can write by declaring everything by steps Recently I found ARRAYS. Idea seems to me understandable but coding it - hmmm different story I got case to be solved Got pool with numbers 1-10 So Local $los[10] For $x=0 To 9 Step +1 $los[$x]=Random(1,10,1) Next I got my first array Bad for me each element from my array got 3 features - color - shape - weight So I assume my new array is a below Local $color = Random(1,4,1) Local $shape = Random(1,4,1) Local $weight = Random(1,4,1) Local $los[10][3] OK so in return I would have 10x [$color, $shape, $weight] But in many occasions features will be identical I would like to have an output " You find eg: 10 elements = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] You got only this xxxxx color (and maybe xxxxx color, up to max 4 colors (whenever color is duplicated do not inform)) You goit only this xxxxxx shape (and maybe this xxxxx shape, up to max 4 shapes (whenever shape is duplicated do not inform)) Your elements weight are as follows eg elements = [1,4,3,4,1,2,3,4,3,4] How to code it ? Edited February 18, 2012 by ddarek Link to comment Share on other sites More sharing options...
water Posted February 18, 2012 Share Posted February 18, 2012 You could use _ArraySort. Sort on a column (color, shape, weight). Then run through the array and only output thos columns where the value is different to the previous value. Local $los[10][3] ; fill $los with your data ; ... ; sort the array on column 1 (shape) _ArraySort($los, 0, 0, 0, 1) $previous = "" For $i = 0 to UBound($los) If $los[$i][1] <> $previous Then ConsoleWrite("Shape " & $los[$i][1]) $previous = $los[$i][1] EndIf Next My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
ddarek Posted February 18, 2012 Author Share Posted February 18, 2012 (edited) Hi THnx for help "fill $los with your data" how to fill 2D array ? First problem like ? Local $color = Random(1,4,1) Local $shape = Random(1,4,1) Local $weight = Random(1,4,1) Local $los[10][3] For $x=0 To 9 Step +1 $los[$x][0]=$color $los[$x][1]=$shape $los[$x][2]=$weight Next Is it correct ? Edited February 18, 2012 by ddarek Link to comment Share on other sites More sharing options...
water Posted February 18, 2012 Share Posted February 18, 2012 (edited) Move Random into the loop. Else you just get identical values. If you don't use your code in a function you should define variables using Global. Global $los[10][3] For $x=0 To 9 $los[$x][0]=Random(1,4,1) $los[$x][1]=Random(1,4,1) $los[$x][2]=Random(1,4,1) Next Edited February 18, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
ddarek Posted February 18, 2012 Author Share Posted February 18, 2012 Thnx for helpI dont know why butFor $i = 0 to UBound($los) doesnt work butFor $i = 0 to UBound($los,0) works fineNow I can get what I wanted Link to comment Share on other sites More sharing options...
water Posted February 18, 2012 Share Posted February 18, 2012 According to the help file parameter 2 stands for the dimension: "Which dimension of a multi-dimensioned array to report the size of. Default is 1, which is the first dimension. If this parameter is 0, the number of subscripts in the array is returned." My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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