Sign in to follow this  
Followers 0
sc4ry

delete both double-entries in array

6 posts in this topic

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

yeah thanks, this works fine =)

Share this post


Link to post
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
Sign in to follow this  
Followers 0