monoscout999 Posted May 18, 2011 Posted May 18, 2011 (edited) hi everyone, i already write a function to get the colors thata are in a rectangle and save the info in an array... Now i have to know which is the most repeated color found in that array not only which appears the most, but whiches follow it in a quantity of times, according to the function paramater The function prototype is _Showmostcolors($ncolors = 1 ,$colorlist) $ncolors = the number of colors witch repeats(the most first and less and less) $colorlist = the color list getting in the _getboxcolors function the function that gets the colors and put them in an array is this.. with an example expandcollapse popupRequireAdmin #include <array.au3> #include "FastFind.au3" FFSetDebugMode(0x01) $start = TimerInit() $colors = _Getboxcolors(10, 0, 15, 15) $diff = TimerDiff($start) ConsoleWrite($diff & @CRLF) _Showmostcolors(1, $colors) ;~ _ArrayDisplay($colors) CloseFFDll() Func _Getboxcolors($x1, $y1, $x2, $y2) Select Case $x1 > $x2 SetError(1) ConsoleWrite("error number " & @error & " Your first x coor must be less than your second x coor") Return False Case $y1 > $y2 SetError(2) ConsoleWrite("error number " & @error & " Your first y coor must be less than your second y coor") Return False EndSelect If $x2 = 0 Then $x2 = @DesktopWidth If $y2 = 0 Then $y2 = @DesktopHeight Local $y = $y1 Local $n = (($x2 + 1) - $x1) * (($y2 + 1) - $y1) Local $colors[$n + 1][3] = [[0, "X", "Y"]] FFSnapShot($x1, $y1, $x2, $y2) For $y = $y1 To $y2 For $x = $x1 To $x2 $colors[0][0] += 1 $n = $colors[0][0] $colors[$n][0] = Hex(FFGetPixel($x, $y, 0)) $colors[$n][1] = $x $colors[$n][2] = $y Next Next Return $colors EndFunc ;==>_Getboxcolors Func _Showmostcolors($ncolors, $colorlist) I use the FastFrench functions that are a lot faster.. but if you want replace FFGetPixel($x , $y,0) for Pixelgetcolor($x, $y) and delete the other FF functions... I´m I'm completely lost whit this... it will be good some help PD: Sorry my bad english Edited May 18, 2011 by monoscout999
monoscout999 Posted May 18, 2011 Author Posted May 18, 2011 a push i only need an idea of how can i do it.. i don´t ask for a code...
hannes08 Posted May 18, 2011 Posted May 18, 2011 (edited) Hi monoscout99, 1. Sort array (using _ArraySort($avArray, 0, 0, 0, 0)) after the first item (color) 2. Now you can walk the array from top to bottom and counting how often the color exists (maybe you want to create a new array for that) Edit: Oh, and please wait some time (let's say 24 hours) before bumping your topic. You could be misunderstood. Edited May 18, 2011 by Hannes123 Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
monoscout999 Posted May 18, 2011 Author Posted May 18, 2011 Hi monoscout99,1. Sort array (using _ArraySort($avArray, 0, 0, 0, 0)) after the first item (color)2. Now you can walk the array from top to bottom and counting how often the color exists (maybe you want to create a new array for that) thanks ¨¨ i need a push with this my brain can{t figureout how to do it... maybe tomorrow i´ll do iti need to figure out how to count and how to select the color witch have more repetitive items..(bad english)
sahsanu Posted May 18, 2011 Posted May 18, 2011 i need to figure out how to count and how to select the color witch have more repetitive items..(bad english) An example you can use as a start: #include <array.au3> Global $aArray[26] = ["a","b","c","d","e","f","a","a","c","e","c","a","f","c","c","e","e","c","f","b","a","c","c","d","b","j"] Global $counting[50][2] $aUnique=_ArrayUnique($aArray) ReDim $counting[$aUnique[0]][2] For $i=1 to $aUnique[0] $number=_ArrayFindAll($aArray,$aUnique[$i]) If IsArray($number) Then $counting[$i-1][0] = $aUnique[$i] $counting[$i-1][1] = UBound($number) EndIf Next _ArraySort($counting,1,"","",1) _ArrayDisplay($counting)
Malkey Posted May 19, 2011 Posted May 19, 2011 .... I use the FastFrench functions that are a lot faster.. but if you want replace FFGetPixel($x , $y,0) for Pixelgetcolor($x, $y) and delete the other FF functions... .... Using this example, the built-in AutoIt PixelGetColor() function tested to be faster than the FFGetPixel() user-defined function from the FastFind.au3 file. expandcollapse popup#include <array.au3> #include "FastFind.au3" Local $start, $colors, $aCol, $diff Local $sAllPix, $sPixels = "" FFSetDebugMode(0x01) $start = TimerInit() $colors = _Getboxcolors(10, 0, 15, 15, $sAllPix, $sPixels) $aCol = _Showmostcolors($sPixels, $sAllPix) $diff = TimerDiff($start) ConsoleWrite($diff & @CRLF) _ArrayDisplay($colors) _ArrayDisplay($aCol) CloseFFDll() Func _Getboxcolors($x1, $y1, $x2, $y2, ByRef $sAllPixels, ByRef $sPix) Select Case $x1 > $x2 SetError(1) ConsoleWrite("error number " & @error & " Your first x coor must be less than your second x coor") Return False Case $y1 > $y2 SetError(2) ConsoleWrite("error number " & @error & " Your first y coor must be less than your second y coor") Return False EndSelect If $x2 = 0 Then $x2 = @DesktopWidth If $y2 = 0 Then $y2 = @DesktopHeight Local $y = $y1 Local $n = (($x2 + 1) - $x1) * (($y2 + 1) - $y1) Local $colors[$n + 1][3] = [[0, "X", "Y"]] FFSnapShot($x1, $y1, $x2, $y2) For $y = $y1 To $y2 For $x = $x1 To $x2 $colors[0][0] += 1 $n = $colors[0][0] ;$colors[$n][0] = "0x" & Hex(FFGetPixel($x, $y, 0),6) ; Time taken 97 milliseconds for 80 colors, 19 milliseconds for 1 colors. $colors[$n][0] = "0x" & Hex(PixelGetColor($x, $y), 6) ; Time taken 91 milliseconds for 80 colors, 12 milliseconds for 1 colors. $colors[$n][1] = $x $colors[$n][2] = $y If StringInStr($sPix, $colors[$n][0]) = 0 Then $sPix &= $colors[$n][0] & "," ; String of unique colours. $sAllPixels &= $colors[$n][0] & "," ; String of all colours. Next Next $sPix = StringTrimRight($sPix, 1) $sAllPixels = StringTrimRight($sAllPixels, 1) Return $colors EndFunc ;==>_Getboxcolors ;Returns a 2D array containing a list of colours (from $sColors parameter), and the number of times each colour exists in the $sColorlist parameter. ;$sColors - A string of the unique colours, separated by a coma, that make up the list of colours in $sColorlist. ;$sColorlist - A string made up of one or more occurrences of each of the $sColors colours. Func _Showmostcolors($sColors, $sColorlist) Local $aArr = StringSplit($sColors, ",") Local $aRet[UBound($aArr)][2] $aRet[0][0] = $aArr[0] For $i = 1 To UBound($aArr) - 1 $aRet[$i][0] = $aArr[$i] StringReplace($sColorlist, $aArr[$i], $aArr[$i]) $aRet[$i][1] = @extended Next _ArraySort($aRet, 1, 1, 0, 1) Return $aRet EndFunc ;==>_Showmostcolors
hannes08 Posted May 19, 2011 Posted May 19, 2011 (edited) This is how you would count the occurances in a 2 - dimensional array. #include <Array.au3> Local $avArray[5][3] $avArray[0][0] = 0 $avArray[0][1] = 0 $avArray[0][2] = 0 $avArray[1][0] = 1 $avArray[1][1] = 0 $avArray[1][2] = 0 $avArray[2][0] = 2 $avArray[2][1] = 0 $avArray[2][2] = 0 $avArray[3][0] = 1 $avArray[3][1] = 0 $avArray[3][2] = 0 $avArray[4][0] = 0 $avArray[4][1] = 0 $avArray[4][2] = 0 Local $aiResult = _ArrayFindAll($avArray, 1, 0, 0, 0, 0, 0) _ArrayDisplay($avArray, "$avArray") _ArrayDisplay($aiResult, "Results of searching for ""1"" in $avArray") @sahsanu: Great function, did't knew that one! Edited May 19, 2011 by Hannes123 Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
monoscout999 Posted May 19, 2011 Author Posted May 19, 2011 (edited) Thanks to all!@sahsanu thats look like i´ve search for... i gonna try it with my 2d array and figure out how to make it work, because the _ArrayUnique() function help says it only work with 1D arrays... but i figure out how to do it.. @Malkey I still don´t know if that is what i look for... about the fffunction() my test in your own script gives me Pixelgetcolor() takes 10338.0370914589 ms to get 15 x 15 area colorsFFGetPixel() takes 82.131965314861 ms... to get 15 x 15 area colorsthis are my tests maybe the OS or something make pixelgetcolor slower... @Hannes123 i almost by pass your answer ... yes thats usefull... later i do an ubound to get the many times that a colour apear..next time i´ll be more patience...(sorry my bad english) Edited May 19, 2011 by monoscout999
BrewManNH Posted May 19, 2011 Posted May 19, 2011 _ArrayUnique will work with a 2D array on the incoming array, the description is incorrect. You just have to use the $iDimension parameter to search on a specific subitem in the array. It will return a 1D array containing the subitems in that array without any duplicates. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
monoscout999 Posted May 19, 2011 Author Posted May 19, 2011 (edited) @BrewManNHI just test it... and it´s ok.. now my problem is how to combine two 1dimensional arrays to one 2dimensional arrayLocal $avArray[5] $avArray[0] = 0 $avArray[1] = 0 $avArray[2] = 0 $avArray[3] = 1 $avArray[4] = 0 Local $avArray2[5] $avArray[0] = 0 $avArray[1] = 2 $avArray[2] = 0 $avArray[3] = 0 $avArray[4] = 1how i can get $avArray[5][2] witch one column is $avArray and the other is $avArray2?EDIT : Sorry... i already correct the script..EDIT2 ; Im trying this#Include <Array.au3> Local $avArray[5] $avArray[0] = 0 $avArray[1] = 0 $avArray[2] = 0 $avArray[3] = 1 $avArray[4] = 0 Local $avArray2[5] $avArray[0] = 0 $avArray[1] = 2 $avArray[2] = 0 $avArray[3] = 0 $avArray[4] = 1 dim $avArray3[5][2] for $i = 0 to ubound($avArray) $avArray3[$i][0] = $avArray[$i] Next for $i = 0 to ubound($avArray2) $avArray3[$i][1] = $avArray2[$i] Next _arraydisplay($avArray3) Edited May 19, 2011 by monoscout999
BrewManNH Posted May 19, 2011 Posted May 19, 2011 (edited) First you need to redefine your arrays, you're reusing elements in each array, so the resulting arrays are not going to be what you think they're going to be. Here are the arrays properly assigned and then concantenated into a 2D array ($avArray3) #include <Array.au3> Global $avArray[5] $avArray[0] = 0 $avArray[1] = 0 $avArray[2] = 0 $avArray[3] = 1 $avArray[4] = 0 _ArrayDisplay($avArray) Global $avArray2[5] $avArray2[0] = 0 $avArray2[1] = 2 $avArray2[2] = 0 $avArray2[3] = 0 $avArray2[4] = 1 Global $avArray3[5][2] _ArrayDisplay($avArray2) For $I = 0 To UBound($avArray) - 1 $avArray3[$I][0] = $avArray[$I] $avArray3[$I][1] = $avArray2[$I] Next _ArrayDisplay($avArray3) EDIT: This will only work if both arrays are of equal size, or the second array has more elements than the first. If the second array has less elements than $avArray it will fail with a subscript error. Edited May 19, 2011 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
monoscout999 Posted May 19, 2011 Author Posted May 19, 2011 ok i just solved... the two arrays are of equal size one cames from the ubound of the other.. thanks
monoscout999 Posted May 19, 2011 Author Posted May 19, 2011 i m still with this... :S it´s become more complicated to me.... i can´t figured out how to extrrac the data that i want from the array...for example: I got an array with two columns... one whit the colors and the other with the times the color repeat it self... instead of repeating the color in the list i want to use some kind of index showing me how many times the color repeat...so i got this array list...Dim $enumcolors[10][2] $enumcolors[0][0] = 9 ; the first element of the first columns says how many colors are in the list $enumcolors[1][0] = 009D9D9C $enumcolors[2][0] = 00B2B4B5 $enumcolors[3][0] = 00596475 $enumcolors[4][0] = 00686B6F $enumcolors[5][0] = 00BCBEBC $enumcolors[6][0] = 00BDBFBF $enumcolors[7][0] = 00B9BEBF $enumcolors[8][0] = 00B9BCBD $enumcolors[9][0] = 00C1C1BF $enumcolors[0][1] = "how of each..." ; the first element of the second column says how many of each color are $enumcolors[1][1] = 1 $enumcolors[2][1] = 1 $enumcolors[3][1] = 7 $enumcolors[4][1] = 2 $enumcolors[5][1] = 2 $enumcolors[6][1] = 2 $enumcolors[7][1] = 8 $enumcolors[8][1] = 6 $enumcolors[9][1] = 6so what i want is to take the colors who have the more high index in the second column using a function in witch parameter i say how many of the colors i want to retrieve... for example... prototipe funciton_getcolor($array,$howmany)$array reffers to the array where the color and his index are..$howmany refers to how many colors i take from that array... for example.. a $howmany value of 1 will take only the elements in the 7 row of the array... because i only want only the wich have the highest number in the second columnExample 2: A $howmany value of 2 will retrive the elements in the elements of the 7 row and the 3 row... in that order, because thata are the 2 with a highest number on his second column...here´s the problem!!!But if i use a $howmany value of 3 i want the function retrieve the elements in 7 row, 3 row, 8 and 9 row... the 8 and 9 row have the same sumber in the second column and i want to take bout... i hope this will be clearily enough to explain what is my problem...Again.. sorry for my bad english and any help will be greatful.... If you want what i got so far only ask me... but the only thing so far is that i have sorted the array and i try using _arraypop() function but still i dont know how to solve the third case of the example....
monoscout999 Posted May 19, 2011 Author Posted May 19, 2011 I did it look tryng to change the function parameter... if you use 1 should return only 1 color(the one with the index 8), if you change it to two it should return 2 colors(8 and 7), but if you change it to 3 it should return 4 colors(8, 7, 6 and 6) expandcollapse popup#include <array.au3> Dim $enumcolors[10][2] $enumcolors[0][0] = 9 ; the first element of the first columns says how many colors are in the list $enumcolors[1][0] = "009D9D9C" $enumcolors[2][0] = "00B2B4B5" $enumcolors[3][0] = "00596475" $enumcolors[4][0] = "00686B6F" $enumcolors[5][0] = "00BCBEBC" $enumcolors[6][0] = "00BDBFBF" $enumcolors[7][0] = "00B9BEBF" $enumcolors[8][0] = "00B9BCBD" $enumcolors[9][0] = "00C1C1BF" $enumcolors[0][1] = "how of each..." ; the first element of the second column says how many of each color are $enumcolors[1][1] = 1 $enumcolors[2][1] = 1 $enumcolors[3][1] = 7 $enumcolors[4][1] = 2 $enumcolors[5][1] = 2 $enumcolors[6][1] = 2 $enumcolors[7][1] = 8 $enumcolors[8][1] = 6 $enumcolors[9][1] = 6 _ArraySort($enumcolors, 1, 1, 0, 1) _ArrayDisplay($enumcolors) $mostusedcolors = _getcolors($enumcolors,4) _ArrayDisplay($mostusedcolors) Func _Getcolors($array, $ncolors) Local $n = 1 Local $mostcol[1] Local $howmany[1] ;~ _arraydisplay ;~ _arraydisplay While 1 _ArrayAdd($howmany, $array[$n][1]) _ArrayAdd($mostcol, $array[$n][0]) ;~ MsgBox(0, "", $n) If $n = $array[0][0] Then ExitLoop If $howmany[$n] = $array[$n+1][1] Then $ncolors += 1 EndIf If $n = $ncolors Then ExitLoop $n += 1 WEnd Local $colorlist[UBound($howmany)][2] ConsoleWrite(UBound($howmany)) For $i = 1 To UBound($howmany) - 1 $colorlist[$i][0] = $mostcol[$i] $colorlist[$i][1] = $howmany[$i] Next $colorlist[0][0] = UBound($colorlist) - 1 $colorlist[0][1] = "How many..." Return $colorlist EndFunc ;==>_Getcolors
monoscout999 Posted May 19, 2011 Author Posted May 19, 2011 (edited) and here you got the two functions... if someone think a easiest way to do it ... please tell me... My own script gives me dizzys! :S expandcollapse popup#RequireAdmin #include <array.au3> #include "FastFind.au3" FFSetDebugMode(0x01) $colors = _Getboxcolors(0, 0, 50, 50) $mostcolors = _Showmostcolors($colors, 3) _ArrayDisplay($colors) _ArrayDisplay($mostcolors) CloseFFDll() Func _Getboxcolors($x1, $y1, $x2, $y2) Select Case $x1 > $x2 SetError(1) ConsoleWrite("error number " & @error & " Your first x coor must be less than your second x coor") Return False Case $y1 > $y2 SetError(2) ConsoleWrite("error number " & @error & " Your first y coor must be less than your second y coor") Return False EndSelect If $x2 = 0 Then $x2 = @DesktopWidth If $y2 = 0 Then $y2 = @DesktopHeight Local $y = $y1 Local $n = (($x2 + 1) - $x1) * (($y2 + 1) - $y1) Local $colors[$n + 1][3] = [[0, "X", "Y"]] FFSnapShot($x1, $y1, $x2, $y2, 0) $start = TimerInit() For $y = $y1 To $y2 For $x = $x1 To $x2 $colors[0][0] += 1 $n = $colors[0][0] $colors[$n][0] = Hex(FFGetPixel($x, $y, 0)) $colors[$n][1] = $x $colors[$n][2] = $y Next Next $diff = TimerDiff($start) ConsoleWrite($diff & @CRLF) Return $colors EndFunc ;==>_Getboxcolors Func _Showmostcolors($colorlist, $ncolors = 0) Local $lcol = _ArrayUnique($colorlist, 1, 1) If $ncolors = 0 Then $ncolors = $lcol[0] Local $rcol[$lcol[0] + 1] = [$lcol[0]] For $i = 1 To $lcol[0] For $n = 1 To $colorlist[0][0] If $lcol[$i] = $colorlist[$n][0] Then $rcol[$i] += 1 EndIf Next Next Dim $enumcolors[$lcol[0] + 1][2] For $i = 0 To UBound($lcol) - 1 $enumcolors[$i][0] = $lcol[$i] $enumcolors[$i][1] = $rcol[$i] Next $enumcolors[0][1] = "how many..." _ArraySort($enumcolors, 1, 1, 0, 1) Local $n = 1 Local $mostcol[1] Local $howmany[1] While 1 _ArrayAdd($howmany, $enumcolors[$n][1]) _ArrayAdd($mostcol, $enumcolors[$n][0]) If $n = $enumcolors[0][0] Then ExitLoop If $howmany[$n] = $enumcolors[$n + 1][1] Then $ncolors += 1 EndIf If $n = $ncolors Then ExitLoop $n += 1 WEnd Local $colorl[UBound($howmany)][2] For $i = 1 To UBound($howmany) - 1 $colorl[$i][0] = $mostcol[$i] $colorl[$i][1] = $howmany[$i] Next $colorl[0][0] = UBound($colorl) - 1 $colorl[0][1] = "How many..." Return $colorl EndFunc ;==>_Showmostcolors Edited May 19, 2011 by monoscout999
sahsanu Posted May 19, 2011 Posted May 19, 2011 (edited) Example 2: A $howmany value of 2 will retrive the elements in the elements of the 7 row and the 3 row... in that order, because thata are the 2 with a highest number on his second column... here´s the problem!!! But if i use a $howmany value of 3 i want the function retrieve the elements in 7 row, 3 row, 8 and 9 row... the 8 and 9 row have the same sumber in the second column and i want to take bout... i hope this will be clearily enough to explain what is my problem... Maybe this could be fine to you. I did it in a hurry so no error check etc. etc.: expandcollapse popup#include <array.au3> Dim $enumcolors[10][2] $enumcolors[0][0] = "9" ; the first element of the first columns says how many colors are in the list $enumcolors[1][0] = "009D9D9C" $enumcolors[2][0] = "00B2B4B5" $enumcolors[3][0] = "00596475" $enumcolors[4][0] = "00686B6F" $enumcolors[5][0] = "00BCBEBC" $enumcolors[6][0] = "00BDBFBF" $enumcolors[7][0] = "00B9BEBF" $enumcolors[8][0] = "00B9BCBD" $enumcolors[9][0] = "00C1C1BF" $enumcolors[0][1] = "how of each..." ; the first element of the second column says how many of each color are $enumcolors[1][1] = "1" $enumcolors[2][1] = "1" $enumcolors[3][1] = "7" $enumcolors[4][1] = "2" $enumcolors[5][1] = "2" $enumcolors[6][1] = "2" $enumcolors[7][1] = "8" $enumcolors[8][1] = "6" $enumcolors[9][1] = "6" $myarray = _getcolor($enumcolors,3) _ArrayDisplay($myarray) Func _getcolor($thearray,$howmany) Local $tachan="" $aSortingNumbers=_ArrayUnique($thearray,2,1) _ArraySort($aSortingNumbers,1,1) If $aSortingNumbers[0] >= $howmany Then For $i=1 to $howmany $result = _ArrayFindAll($thearray,$aSortingNumbers[$i],1,0,0,0,1) For $j=0 To UBound($result)-1 $tachan &= $thearray[$result[$j]][0] & "|" Next Next $tachan=StringTrimRight($tachan,1) $tachan = StringSplit($tachan,"|") Return $tachan Else MsgBox(0,"Error","Not enought howmany to search ;-)") Return SetError(1,0,-1) EndIf EndFunc ;===> _getcolor() Edit: This forum does not like dollar sign so my StringRegExp function does not appeares as it should. I've changed it to StringTrimRight so now should work fine. Edited May 19, 2011 by sahsanu
monoscout999 Posted May 19, 2011 Author Posted May 19, 2011 Maybe this could be fine to you. I did it in a hurry so no error check etc. etc.: expandcollapse popup#include <array.au3> Dim $enumcolors[10][2] $enumcolors[0][0] = "9" ; the first element of the first columns says how many colors are in the list $enumcolors[1][0] = "009D9D9C" $enumcolors[2][0] = "00B2B4B5" $enumcolors[3][0] = "00596475" $enumcolors[4][0] = "00686B6F" $enumcolors[5][0] = "00BCBEBC" $enumcolors[6][0] = "00BDBFBF" $enumcolors[7][0] = "00B9BEBF" $enumcolors[8][0] = "00B9BCBD" $enumcolors[9][0] = "00C1C1BF" $enumcolors[0][1] = "how of each..." ; the first element of the second column says how many of each color are $enumcolors[1][1] = "1" $enumcolors[2][1] = "1" $enumcolors[3][1] = "7" $enumcolors[4][1] = "2" $enumcolors[5][1] = "2" $enumcolors[6][1] = "2" $enumcolors[7][1] = "8" $enumcolors[8][1] = "6" $enumcolors[9][1] = "6" $myarray = _getcolor($enumcolors,3) _ArrayDisplay($myarray) Func _getcolor($thearray,$howmany) Local $tachan="" $aSortingNumbers=_ArrayUnique($thearray,2,1) _ArraySort($aSortingNumbers,1,1) If $aSortingNumbers[0] >= $howmany Then For $i=1 to $howmany $result = _ArrayFindAll($thearray,$aSortingNumbers[$i],1,0,0,0,1) For $j=0 To UBound($result)-1 $tachan &= $thearray[$result[$j]][0] & "|" Next Next $tachan=StringTrimRight($tachan,1) $tachan = StringSplit($tachan,"|") Return $tachan Else MsgBox(0,"Error","Not enought howmany to search ;-)") Return SetError(1,0,-1) EndIf EndFunc ;===> _getcolor() Edit: This forum does not like dollar sign so my StringRegExp function does not appeares as it should. I've changed it to StringTrimRight so now should work fine. It have a little mistiping problem but it works.. i read your edit yes it works fine... still doesn´t understand how but it works... maybe my head need to rest. thanks
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