## Recommended Posts

been working on this function for longer then i'd care to mention, almost to the point of pulling my hair out lol

ok heres the code so far:

```Func _arraydeldupes3d(\$adel_arr, \$adel_col)
\$inc = 0
While 1
\$inc += 1
If \$inc > UBound(\$adel_arr) -1 Then
EndIf
EndIf
\$inc = \$inc - 1
ExitLoop
EndIf
Next
WEnd
EndFunc```

you'll need _ArrayDelete4D() which can find from search.

execute as follows: _arraydeldupes3d(array, column_number)

does this code seem ok to you? if you have any suggestions pls help ##### Share on other sites

been working on this function for longer then i'd care to mention, almost to the point of pulling my hair out lol

ok heres the code so far:

```Func _arraydeldupes3d(\$adel_arr, \$adel_col)
\$inc = 0
While 1
\$inc += 1
If \$inc > UBound(\$adel_arr) -1 Then
EndIf
EndIf
\$inc = \$inc - 1
ExitLoop
EndIf
Next
WEnd
EndFuncoÝ÷ Û*.ßÙeçºÚÈ7¥z×¸brø§uúèÇ­È^Åç.µæ¬~e£®¶²ué]º¬ÝÖ«­¬¢[¦{¦mêÝ¡ë-+¡×¬yé¨Ú2¢èÊ¡j÷+.¬¶*'²léiþ«¨µäáÉbë!£2¢æ«y×)àÂ+aØ6«­¬¬w
«­¢+Ù]¡Ðµå½ÔÑ¡¥¹¬¥ÐÝÌÍ```

So when your function finds a duplicate in the 2D array, what is it supposed to do? Delete the row? Delete the column? Delete the value? Does it work for you? Do you have an actual test script that can be run? 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

##### Share on other sites

sorry, the function _arraydeldupes3d() looks for duplicate entries in a selected column from a 2-dimensional array, if it detects a dupilcate it will delete the entire row. yes it seems to be working for me, i was wondering if someone could double check the code for me, i think my ubound calls might be a little hairy. here is an example, including another small function which converts the result into combo box format. about the 3D, i was just unsure what to call it.

```#include <array.au3>

global \$test_arr
\$test_arr = "just"
\$test_arr = "another"
\$test_arr = "day"
\$test_arr = "in"
\$test_arr = "another"
\$test_arr = "just"
\$test_arr = "day"
\$test_arr = "another"

_ArrayDisplay(\$test_arr, "original array")
\$test_arr = _arraydeldupes3d(\$test_arr, 1)
_ArrayDisplay(\$test_arr, "after _arraydeldupes3d()")
\$test_combo_string = _array2combo3D(\$test_arr, 1)
MsgBox(0, "array to combo box format", \$test_combo_string)

\$inc = 0
While 1
\$inc += 1
If \$inc > UBound(\$adel_arr) -1 Then
EndIf
EndIf
\$inc = \$inc - 1
ExitLoop
EndIf
Next
WEnd
EndFunc

Func _array2combo3D(\$a2c_arr, \$a2c_col)
Dim \$a2c_str
\$a2c_i = 1
For \$a2c_i = 1 to UBound(\$a2c_arr) - 1
\$a2c_str = \$a2c_str & "|" & \$a2c_arr[\$a2c_i][\$a2c_col]
Next
Return \$a2c_str
EndFunc

Func _ArrayDelete4D(ByRef \$avInput, \$iElement)
If (Not IsArray(\$avInput)) Or (Not IsInt(\$iElement)) Then Return SetError(1, 0, 0) ; Wrong type of input(s)
Local \$e, \$f, \$g, \$h
Local \$avUbounds[UBound(\$avInput, 0) + 1] = [UBound(\$avInput, 0)]
For \$e = 1 to \$avUbounds
\$avUbounds[\$e] = UBound(\$avInput, \$e)
Next
If \$avUbounds > 4 Then Return SetError(2, 0, 0) ; Array has more than four subscripts
If \$avUbounds = 1 Then Return SetError(3, 0, 0) ; Array only has one element
If \$iElement > \$avUbounds - 1 Or \$iElement < 0 Then Return SetError(4, 0, 0) ; \$iElement out of range
If \$iElement <> \$avUbounds - 1 Then
For \$e = \$iElement To \$avUbounds - 2
Switch \$avUbounds
Case 1
\$avInput[\$e] = \$avInput[\$e + 1]
Case 2
For \$f = 0 To \$avUbounds - 1
\$avInput[\$e][\$f] = \$avInput[\$e + 1][\$f]
Next
Case 3
For \$f = 0 To \$avUbounds - 1
For \$g = 0 To \$avUbounds - 1
\$avInput[\$e][\$f][\$g] = \$avInput[\$e + 1][\$f][\$g]
Next
Next
Case 4
For \$f = 0 To \$avUbounds - 1
For \$g = 0 To \$avUbounds - 1
For \$h = 0 To \$avUbounds - 1
\$avInput[\$e][\$f][\$g][\$h] = \$avInput[\$e + 1][\$f][\$g][\$h]
Next
Next
Next
EndSwitch
Next
EndIf
Switch \$avUbounds
Case 1
ReDim \$avInput[\$avUbounds - 1]
Case 2
ReDim \$avInput[\$avUbounds - 1][\$avUbounds]
Case 3
ReDim \$avInput[\$avUbounds - 1][\$avUbounds][\$avUbounds]
Case 4
ReDim \$avInput[\$avUbounds - 1][\$avUbounds][\$avUbounds][\$avUbounds]
EndSwitch
Return 1
EndFunc   ;==>_ArrayDelete3D```
Edited by laffo16

##### Share on other sites

Well, if it works, that's the main thing. It might be slow because of all the iterative looping through the array, but functionality comes first.

And if the name is going to be unrelated to the actual function's properties, you should have named it _Abigail(). I like the name Abigail. 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

##### Share on other sites

Hi,

```]#include <array.au3>
Dim \$ar, \$ar2
\$ar = "otto"
\$ar = "aha"
\$ar = "otto"
\$ar = "b"
\$ar = "aha"

\$ar2 = "otto"
\$ar2 = "aha"
\$ar2 = "otto"
\$ar2 = "b"
\$ar2 = "ah"
\$ar2 = "c"
\$ar2 = "ha"
\$ar2 = "c"
\$ar2 = "bor"
\$ar2 = "aha"

_ArrayDisplay(\$ar, "1D mit Doppel")
_Array2DDblDel(\$ar)
_ArrayDisplay(\$ar, "1D Doppel gelöscht")

_ArrayDisplay(\$ar2, "2D mit Doppel")
_Array2DDblDel(\$ar2)
_ArrayDisplay(\$ar2, "2D Doppel gelöscht")

;----------------------------------------------------------------------------------------------------------------------
; Function        _Array2DDblDel(ByRef \$ARRAY [, \$CASESENS=0])
;
; Description    - From an 1D/2D Array will delete double entries (2D -> combination by '[n]' to '[n][x]').
;                - Autodetection 1D/2D Array
;                - By using string, you can choose case sensitivity.
;
; Parameter        \$ARRAY:            Array to sort
;    optional    \$CASESENS:        Case sensitivity off or on (default 0)
;
; Return        Succes            ByRef Array without doubles
;                                Count of doubles
;                Failure            0 and set @error = 1; no array
;
; Author        BugFix (bugfix@autoit.de)
;----------------------------------------------------------------------------------------------------------------------
Func _Array2DDblDel(ByRef \$ARRAY, \$CASESENS=0)
Local \$iDIM, \$arTmp = [''], \$dbl = 0, \$count = 0
If ( Not IsArray(\$ARRAY) ) Then
SetError(1)
Return 0
EndIf
\$Ubound2nd = UBound(\$ARRAY,2)
If @error = 2 Then
For \$i = 0 To UBound(\$ARRAY)-1
\$dbl = 0
For \$k = 0 To UBound(\$arTmp)-1
Switch \$CASESENS
Case 0
If \$arTmp[\$k] = \$ARRAY[\$i] Then
\$dbl = 1
\$count += 1
EndIf
Case 1
If \$arTmp[\$k] == \$ARRAY[\$i] Then
\$dbl = 1
\$count += 1
EndIf
EndSwitch
Next
If \$dbl = 0 Then
If \$arTmp = "" Then
\$arTmp = \$ARRAY[\$i]
Else
ReDim \$arTmp[UBound(\$arTmp)+1]
\$arTmp[UBound(\$arTmp)-1] = \$ARRAY[\$i]
EndIf
Else
\$dbl = 0
EndIf
Next
Else
ReDim \$arTmp[\$Ubound2nd]
\$arTmp = ''
\$x = 0
For \$i = 0 To UBound(\$ARRAY)-1
\$dbl = 0
\$val = ''
\$valTmp = ''
For \$l = 0 To \$Ubound2nd-1
\$val &= \$ARRAY[\$i][\$l]
Next
For \$k = 0 To UBound(\$arTmp)-1
For \$l = 0 To \$Ubound2nd-1
\$valTmp &= \$arTmp[\$k][\$l]
Next
Switch \$CASESENS
Case 0
If  \$valTmp = \$val Then
\$dbl = 1
\$count += 1
EndIf
Case 1
If  \$valTmp == \$val Then
\$dbl = 1
\$count += 1
EndIf
EndSwitch
Next
If \$dbl = 0 Then
If \$x = 1 Then ReDim \$arTmp[UBound(\$arTmp)+1][\$Ubound2nd]
For \$l = 0 To \$Ubound2nd-1
If \$arTmp = '' Or \$x = 0 Then
\$arTmp[\$l] = \$ARRAY[\$l]
If \$l = \$Ubound2nd-1 Then \$x = 1
Else
\$arTmp[UBound(\$arTmp)-1][\$l] = \$ARRAY[\$i][\$l]
\$x = 2
If \$l = \$Ubound2nd-1 Then \$x = 1
EndIf
Next
Else
\$dbl = 0
EndIf
Next
EndIf
\$ARRAY = \$arTmp
Return \$count
EndFunc ; ==>_ArrayDblDel```

So long,

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...