Jump to content

delete both double-entries in array


sc4ry
 Share

Recommended Posts

hello,

i´m searching for an script, which deletes entries in an array.

i have 2 arrays, which i join with array2djoin. after this i want to delete all entries, which are 2 times or more in the new array.

after this, the new array should only contain entries, which was in the first OR the second array.

arrayunique does not work, because it does only delete one of double-entrie.

do you know such a script?

Link to comment
Share on other sites

hello,

i´m searching for an script, which deletes entries in an array.

i have 2 arrays, which i join with array2djoin. after this i want to delete all entries, which are 2 times or more in the new array.

after this, the new array should only contain entries, which was in the first OR the second array.

arrayunique does not work, because it does only delete one of double-entrie.

do you know such a script?

I am not familiar with 'arrayunique' but if it works you could just run it in a loop until no duplicates were found.

:)

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
Link to comment
Share on other sites

when there are 2 entries which are the same, it deletes one of them, so after using it, there are no more doubles in it.

after that it will do nothing, cause it can´t find any doubles ... that does not work =)

this is the arrayunique-function.

i think that this could be modified, that it deletes both entries and then only returns entrys without doubles ... but i don´t understand the technique of arrayunique =)

Func _ArrayUnique(ByRef $aArray, $vDelim = '', $iBase = 1, $iUnique = 1)
    If $vDelim = '' Then $vDelim = Chr(01)
    Local $sHold
    For $iCC = $iBase To UBound($aArray) - 1
        If Not StringInStr($vDelim & $sHold, $vDelim & $aArray[$iCC] & $vDelim, $iUnique) Then _
                $sHold &= $aArray[$iCC] & $vDelim
    Next
    Return StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim)
EndFunc   ;==>_ArrayUnique
Edited by sc4ry
Link to comment
Share on other sites

  • Moderators

when there are 2 entries which are the same, it deletes one of them, so after using it, there are no more doubles in it.

after that it will do nothing, cause it can´t find any doubles ... that does not work =)

this is the arrayunique-function.

i think that this could be modified, that it deletes both entries and then only returns entrys without doubles ... but i don´t understand the technique of arrayunique =)

Func _ArrayUnique(ByRef $aArray, $vDelim = '', $iBase = 1, $iUnique = 1)
    If $vDelim = '' Then $vDelim = Chr(01)
    Local $sHold
    For $iCC = $iBase To UBound($aArray) - 1
        If Not StringInStr($vDelim & $sHold, $vDelim & $aArray[$iCC] & $vDelim, $iUnique) Then _
                $sHold &= $aArray[$iCC] & $vDelim
    Next
    Return StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim)
EndFunc   ;==>_ArrayUnique
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

I can't edit the last post??? :)

Anyway, I think I understand now... try this and see if it works:

Func _ArrayTotalUnique(ByRef $aArray, $vDelim = '', $iBase = 1, $iUnique = 1)
    If $vDelim = '' Then $vDelim = Chr(01)
    Local $sHold, $sHoldArray
    For $iCC = $iBase To UBound($aArray) - 1
        $sHoldArray &= $aArray[$iCC] & $vDelim
    Next
    For $iCC = $iBase To UBound($aArray) - 1
        If Not StringInStr($vDelim & $sHoldArray, $vDelim & $aArray[$iCC] & $vDelim, $iUnique, 2) Then _
                $sHold &= $aArray[$iCC] & $vDelim
    Next
    Return StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim)
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...