Zur Zeit sind keine Benutzer aktiv.
Lieber Besucher, herzlich willkommen bei: AutoIt.de - Das deutsche AutoIt-Forum. Falls dies dein erster Besuch auf dieser Seite ist, lies bitte die Hilfe durch. Dort wird dir die Bedienung dieser Seite näher erläutert. Darüber hinaus solltest du dich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutze das Registrierungsformular, um dich zu registrieren oder informiere dich ausführlich über den Registrierungsvorgang. Falls du dich bereits zu einem früheren Zeitpunkt registriert hast, kannst du dich hier anmelden.
, Großvater und ich auf Bugs gestoßen und bemerkt das die Funktion ziemlich langsam ist !
Spoiler
![]()
AutoIt-Quellcode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayUnique ; Description ...: Returns the Unique Elements of a 1-dimensional array. ; Syntax.........: _ArrayUnique($aArray[, $iDimension = 1[, $iBase = 0[, $iCase = 0[, $vDelim = "|"]]]]) ; Parameters ....: $aArray - The Array to use ; $iDimension - [optional] The Dimension of the Array to use ; $iBase - [optional] Is the Array 0-base or 1-base index. 0-base by default ; $iCase - [optional] Flag to indicate if the operations should be case sensitive. ; 0 = not case sensitive, using the user's locale (default) ; 1 = case sensitive ; 2 = not case sensitive, using a basic/faster comparison ; $vDelim - [optional] One or more characters to use as delimiters. However, cannot forsee its usefullness ; $iFlag - flag = 0 (default), it acts each included in the delimiter character as a separator mark ; flag = 1, it is the entire separator string used as a separator mark ; flag = 2, turned off the return of the number in the first element. Thus, the array is 0-based. ; It has to be now UBound () the size of the array. ; Return values .: Success - Returns a 1-dimensional array containing only the unique elements of that Dimension ; Failure - Returns 0 and Sets @Error: ; 0 - No error. ; 1 - Returns 0 if parameter is not an array. ; 2 - Array dimension is invalid, should be an integer greater than 0 ; Author ........: SmOke_N ; Modified.......: litlmike, [Kleiner & Großvater & UEZ (:.AutoIT.de.:)] ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func __ArrayUnique(Const ByRef $aArray, $iDimension = 0, Const $iBase = 0, Const $iCase = 0, $vDelim = '|', Const $iFlag = 0) If Not IsArray($aArray) Or UBound($aArray, 0) > 2 Then Return SetError(1, 0, -1) If ($iFlag < 0 Or $iFlag > 2) Then Return SetError(3, 0, -2) If ($vDelim = '|' Or Not $vDelim) Then $vDelim = Chr(01) Local $iUboundDim = UBound($aArray) Local $sHold If Not UBound($aArray, 2) Then For $I = $iBase To $iUboundDim - 1 If Not StringInStr($sHold & $vDelim, $vDelim & $aArray[$I] & $vDelim, $iCase) Then $sHold &= $vDelim & $aArray[$I] Next Else If ($iDimension > (UBound($aArray, 2) - 1) Or $iDimension < 0) Then Return SetError(3, 0, -2) For $I = $iBase To $iUboundDim - 1 If Not StringInStr($sHold & $vDelim, $vDelim & $aArray[$I][$iDimension] & $vDelim, $iCase) Then $sHold &= $vDelim & $aArray[$I][$iDimension] Next EndIf If $sHold Then Return StringSplit(StringTrimLeft($sHold, StringLen($vDelim)), $vDelim, $iFlag) Return SetError(2, 0, 0) EndFunc ;==>__ArrayUnique
Dieser Beitrag wurde bereits 11 mal editiert, zuletzt von »Kleiner« (11. November 2010, 16:26)


Spoiler
Spoiler
Funktionen: _GUICtrlMenu_CreateBitmap() v0.60 Build 2012-01-07 beta, _GUIImageList_AddBitmapEx() v0.80 Build 2011-11-05 Beta, nNumber v0.90 Build 2010-11-11 Beta, Process Info v0.35 Beta, File_Seeker v0.85 Build 2010-12-01 Beta, Get_Schtasks v0.90 build 2010-12-30 Beta, _WinAPI_SetWindowTitleIcon v0.96 Build 2012-06-03 Beta
GDI: GDI+ Beispiele, Visualization: Analog Meter, Plasma Variante, Screensaver, Rotating Letters, (einige mehr GDI+ Beispiele ), GDI+ Image Rotator and Saver Build 2009-12-23, GDI+ Rotating Cubes, GDI+ Zoomer, GDI+ Visualizer Oscilloscope Farbrausch Build 2010-09-08, GDI+ Pixel Text Effect Beta Build 2010-10-21, GDI+ Simple Clock build 2011-04-06, GDI+ Buchstaben Rotation, GDI+ Perfect Illusion Build 2011-06-02
Misc: Play Chip Sound from Memory, Simple Image Slideshow v1.0 Build 2011-04-30 Beta
Progs: SIC2 v2.0.1 Build 2012-02-24 Beta inkl. GUI, Integer<=>Binary Converter v1.0 Build 2011-09-19, Fussball Chronograph v1.4 Build 2010-03-09, AutoIt Windows Screenshooter v1.65 Build 2013-02-22, Tiny URL Downloader v0.96 Build 2011-01-24, Head - Tail v0.65 Build 2011-03-15 Beta, Check Ping Status v1.03 Build 2013-02-28 Beta, Uptime v0.76 Build 2011-12-13, AD Tools, ISO Creator v1.16 build 2012-09-11 beta, File to Base64 String Code Generator v1.12 Build 2013-03-25
Spiel: AUTOITEROIDS v1.019 Build 2012-07-30
UDF: Write Text on Bitmap.au3 v0.92 Build 2011-05-28 Beta, ArrayUnique v0.96 Build 2010-11-20 Beta, Get_Image_Info v0.80 Build 2011-05-03 Beta, Shuffle_Array v0.50 build 2011-05-24 beta
Spoiler
![]()
AutoIt-Quellcode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 #include <Array.au3> ;~ Dim $aNames[10][2] = [["Anton", ""], ["Berta", 15]] Dim $aNames[10] = ["Antonia", "Anton", "Cäsar", "Dora", "Emil", "Friedrich", "Gustav", "Heinrich", "Ida", "Julius"] Dim $aUnique[100000] For $I = 0 To Ubound($aUnique) - 1 $r = Random(0, 9, 1) $aUnique[$I] = $aNames[$r] Next $ts = TimerInit() $test = ArrayUnique($aUnique) $te = TimerDiff($ts) ConsoleWrite(Round($te, 2) & " ms." & @CRLF) _ArrayDisplay($test) Dim $aNames[10][2] = [["Antonia", ""], ["Anton", ""], ["Cäsar", 300], ["Dora", 24], ["Emil", 33], ["Friedrich", 57], ["Gustav", 53], ["Heinrich", 34], ["Ida", 13], ["Julius", 77]] Dim $aUnique[100000][2] For $I = 0 To Ubound($aUnique) - 1 $r = Random(0, 9, 1) $aUnique[$I][0] = $aNames[$r][0] $aUnique[$I][1] = $aNames[$r][1] Next $ts = TimerInit() $test = ArrayUnique($aUnique) $te = TimerDiff($ts) ConsoleWrite(Round($te, 2) & " ms." & @CRLF) _ArrayDisplay($test) ; #FUNCTION# ===================================================================================================================== ; Name.............: ArrayUnique ; Description ...: Returns the Unique Elements of a 1-dimensional or 2-dimensional array. ; Syntax...........: _ArrayUnique($aArray[, $iBase = 0, oBase = 0, $iCase = 0]) ; Parameters ...: $aArray - The Array to use ; $iBase - [optional] Is the input Array 0-base or 1-base index. 0-base by default ; $oBase - [optional] Is the output Array 0-base or 1-base index. 0-base by default ; $iCase - [optional] Flag to indicate if the operations should be case sensitive. ; 0 = not case sensitive, using the user's locale (default) ; 1 = case sensitive ; 2 = not case sensitive, using a basic/faster comparison ; Return values: Success - Returns a 1-dimensional or 2-dimensional array containing only the unique elements of that Dimension ; Failure - Returns 0 and Sets @Error: ; 0 - No error. ; 1 - Returns 0 if parameter is not an array. ; 2 - Array has more than 2 dimensions ; 3 - Array is already unique ; 4 - when source array is selected as one base but UBound(array) - 1 <> array[0] / array[0][0] ; 5 - Scripting.Dictionary cannot be created for 1D array unique code ; Author .........: UEZ 2010 for 2D-array, Yashied for 1D-array (modified by UEZ) ; Version ........: 0.96 Build 2010-11-20 Beta ; ================================================================================================================================ Func ArrayUnique($aArray, $iBase = 0, $oBase = 0, $iCase = 0) If Not IsArray($aArray) Then Return SetError(1, 0, 0) ;not an array If UBound($aArray, 0) > 2 Then Return SetError(2, 0, 0) ;array is greater than a 2D array If UBound($aArray) = $iBase + 1 Then Return SetError(3, 0, $aArray) ;array is already unique because of only 1 element Local $dim = UBound($aArray, 2), $i If $dim Then ;2D array If $iBase And UBound($aArray) - 1 <> $aArray[0][0] Then Return SetError(4, 0, 0) Local $oD = ObjCreate('Scripting.Dictionary') If @error Then Return SetError(5, 0, 0) Local $i, $j, $k = $oBase, $l, $s, $aTmp, $flag, $sSep = Chr(01) Local $aUnique[UBound($aArray)][$dim] If Not $oBase Then $flag = 2 For $i = $iBase To UBound($aArray) - 1 For $j = 0 To $dim - 1 $s &= $aArray[$i][$j] & $sSep Next If Not $oD.Exists($s) And StringLen($s) > 3 Then $oD.Add($s, $i) $aTmp = StringSplit(StringTrimRight($s, 1), $sSep, 2) For $l = 0 To $dim - 1 $aUnique[$k][$l] = $aTmp[$l] Next $k += 1 EndIf $s = "" Next $oD.RemoveAll If $k > 0 Then If $oBase Then $aUnique[0][0] = $k - 1 ReDim $aUnique[$k][$dim] Else ReDim $aUnique[1][$dim] EndIf Else ;1D array If $iBase And UBound($aArray) - 1 <> $aArray[0] Then Return SetError(4, 0, 0) Local $sData = '', $sSep = ChrW(160), $flag For $i = $iBase To UBound($aArray) - 1 If Not IsDeclared($aArray[$i] & '$') Then Assign($aArray[$i] & '$', 0, 1) $sData &= $aArray[$i] & $sSep EndIf Next If Not $oBase Then $flag = 2 Local $aUnique = StringSplit(StringTrimRight($sData, 1), $sSep, $flag) EndIf Return SetError(0, 0, $aUnique) EndFunc ;==>ArrayUnique
Spoiler
Funktionen: _GUICtrlMenu_CreateBitmap() v0.60 Build 2012-01-07 beta, _GUIImageList_AddBitmapEx() v0.80 Build 2011-11-05 Beta, nNumber v0.90 Build 2010-11-11 Beta, Process Info v0.35 Beta, File_Seeker v0.85 Build 2010-12-01 Beta, Get_Schtasks v0.90 build 2010-12-30 Beta, _WinAPI_SetWindowTitleIcon v0.96 Build 2012-06-03 Beta
GDI: GDI+ Beispiele, Visualization: Analog Meter, Plasma Variante, Screensaver, Rotating Letters, (einige mehr GDI+ Beispiele ), GDI+ Image Rotator and Saver Build 2009-12-23, GDI+ Rotating Cubes, GDI+ Zoomer, GDI+ Visualizer Oscilloscope Farbrausch Build 2010-09-08, GDI+ Pixel Text Effect Beta Build 2010-10-21, GDI+ Simple Clock build 2011-04-06, GDI+ Buchstaben Rotation, GDI+ Perfect Illusion Build 2011-06-02
Misc: Play Chip Sound from Memory, Simple Image Slideshow v1.0 Build 2011-04-30 Beta
Progs: SIC2 v2.0.1 Build 2012-02-24 Beta inkl. GUI, Integer<=>Binary Converter v1.0 Build 2011-09-19, Fussball Chronograph v1.4 Build 2010-03-09, AutoIt Windows Screenshooter v1.65 Build 2013-02-22, Tiny URL Downloader v0.96 Build 2011-01-24, Head - Tail v0.65 Build 2011-03-15 Beta, Check Ping Status v1.03 Build 2013-02-28 Beta, Uptime v0.76 Build 2011-12-13, AD Tools, ISO Creator v1.16 build 2012-09-11 beta, File to Base64 String Code Generator v1.12 Build 2013-03-25
Spiel: AUTOITEROIDS v1.019 Build 2012-07-30
UDF: Write Text on Bitmap.au3 v0.92 Build 2011-05-28 Beta, ArrayUnique v0.96 Build 2010-11-20 Beta, Get_Image_Info v0.80 Build 2011-05-03 Beta, Shuffle_Array v0.50 build 2011-05-24 beta
Dieser Beitrag wurde bereits 10 mal editiert, zuletzt von »UEZ« (26. November 2010, 12:38)
!und schau mal, was dem armen Bert passiert.
Spoiler
![]()
AutoIt-Quellcode
1 2 3 4 5 6 7 8 9 10 11 12 #include <Array.au3> ;~ Dim $aNames[10][2] = [["Anton", ""], ["Berta", 15]] Dim $aNames[10][2] = [["Anton", ""], ["Berta", 15], ["Bert", 300], ["Dora", 24], ["Emil", 33], ["Friedrich", 57], ["Gustav", 53], ["Heinrich", 34], ["Ida", 13], ["Julius", 77]] Dim $aUnique[10000][2] For $I = 0 To Ubound($aUnique) - 1 $r = Random(0, 9, 1) $aUnique[$I][0] = $aNames[$r][0] $aUnique[$I][1] = $aNames[$r][1] Next $test = ArrayUnique($aNames) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $test = ' & $test & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console _ArrayDisplay($test)

Spoiler
![]()
AutoIt-Quellcode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayUnique ; Description ...: Returns the Unique Elements of a 1D or 2D array. ; Syntax.........: _ArrayUnique($aArray[, $iColumn = 1[, $iBase = 0[, $iCase = 0[, $vDelim = "|"]]]]) ; Parameters ....: $aArray - The Array to use ; $iColumn - [optional] 1-based column index for the 2nd dimension of the Array to use ; $iBase - [optional] Is the Array 0-base or 1-base index. 0-base by default ; $iCase - [optional] Flag to indicate if the operations should be case sensitive. ; |0 = not case sensitive, using the user's locale (default) ; |1 = case sensitive ; |2 = not case sensitive, using a basic/faster comparison ; $vDelim - [optional] One or more characters to use as delimiters. However, cannot forsee its usefullness ; Return values .: Success - Returns a 1-dimensional array containing only the unique elements of that Dimension ; Failure - Returns 0 and Sets @Error: ; |1 - Array is not valid. ; |2 - _ArrayUnique failed for some other reason ; |3 - Column index is invalid, should be an integer greater than 0 ; Author ........: SmOke_N ; Modified.......: litlmike, [Kleiner & Großvater & UEZ (:.AutoIT.de.:)] ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func __ArrayUnique(Const ByRef $aArray, Const $iColumn = 1, Const $iBase = 0, Const $iCase = 0, $vDelim = '|') ;Check to see if it is valid array If Not IsArray($aArray) Or UBound($aArray, 0) > 2 Then Return SetError(1, 0, 0) ;Check to see if dimension is valid If UBound($aArray, 0) = 2 And ($iColumn < 1 Or $iColumn > UBound($aArray, 2)) Then Return SetError(3, 0, 0) If ($vDelim = '|') Then $vDelim = Chr(01) ; by SmOke_N, modified by litlmike Local $iRows = UBound($aArray) ;Number of rows in the array Local $iLen = StringLen($vDelim) ;Length of delimiter Local $sHold = $vDelim ;String that holds the Unique array info If UBound($aArray, 0) = 1 Then ; 1D array For $I = $iBase To $iRows - 1 ;If Not the case that the element is already in $sHold, then add it If Not StringInStr($sHold, $vDelim & $aArray[$I] & $vDelim, $iCase) Then $sHold &= $aArray[$I] & $vDelim Next Else ; 2D array For $I = $iBase To $iRows - 1 ;If Not the case that the element is already in $sHold, then add it If Not StringInStr($sHold, $vDelim & $aArray[$I][$iColumn - 1] & $vDelim, $iCase) Then $sHold &= $aArray[$I][$iColumn - 1] & $vDelim Next EndIf If StringLen($sHold) > $iLen Then Return StringSplit(StringMid($sHold, $iLen + 1, StringLen($sHold) - $iLen * 2), $vDelim, 2 - $iBase) ; <-- 2 - $iBase by UEZ Return SetError(2, 0, 0) ;If the script gets this far, it has failed EndFunc ;==>__ArrayUnique
Eine Variable zu abfrage reicht
dann werd ich eure Funktion nehmen
.