Sign in to follow this  
Followers 0
ken82m

UDF to do _ArrayDelete on Multi-Dim Array

4 posts in this topic

Does anyone happen to have a UDF that will allow you to delete a row in an array with more than one column?

I can create a new array just a pain to do code everytime I need to do it.

Thanks,

Kenny


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites



No problem :)

;----------------------------------------------------------------------------------------------------------------------
;   Fuction         _Array2DDelete(ByRef $ARRAY, $iDEL, $bCOL=False)
;
;   Description     Delete one row on a given index in an 1D/2D -Array
;
;   Parameter       $ARRAY      the array, where one row will deleted
;                   $iDEL       Row(Column)-Index to delete
;                   $bCOL       If True, delete column instead of row (default False)
;  
;   Return          Succes      0   ByRef $ARRAY
;                   Failure     1   set @error = 1; given array are not array
;                                   set @error = 2; want delete column, but not 2D-array
;                                   set @error = 3; index is out of range
;
; Author            BugFix (bugfix@autoit.de)
;----------------------------------------------------------------------------------------------------------------------
Func _Array2DDelete(ByRef $ARRAY, $iDEL, $bCOL=False)
    If ( Not IsArray($ARRAY) ) Then Return SetError(1,0,1)
    Local $UBound2nd = UBound($ARRAY,2), $k
    If $bCOL Then 
        If $UBound2nd = 0 Then Return SetError(2,0,1)
        If ( $iDEL < 0 ) Or ( $iDEL > $UBound2nd-1 ) Then Return SetError(3,0,1)
    Else
        If ( $iDEL < 0 ) Or ( $iDEL > UBound($ARRAY)-1 ) Then Return SetError(3,0,1)
    EndIf
    If $UBound2nd = 0 Then
        Local $arTmp[UBound($ARRAY)-1]
        $k = 0
        For $i = 0 To UBound($ARRAY)-1
            If $i <> $iDEL Then 
                $arTmp[$k] = $ARRAY[$i]
                $k += 1
            EndIf
        Next
    Else
        If $bCOL Then
            Local $arTmp[UBound($ARRAY)][$UBound2nd-1]
            For $i = 0 To UBound($ARRAY)-1
                $k = 0
                For $l = 0 To $UBound2nd-1
                    If $l <> $iDEL Then
                        $arTmp[$i][$k] = $ARRAY[$i][$l]
                        $k += 1
                    EndIf
                Next
            Next
        Else
            Local $arTmp[UBound($ARRAY)-1][$UBound2nd]
            $k = 0
            For $i = 0 To UBound($ARRAY)-1
                If $i <> $iDEL Then
                    For $l = 0 To $UBound2nd-1
                        $arTmp[$k][$l] = $ARRAY[$i][$l]
                    Next
                    $k += 1
                EndIf
            Next
        EndIf
    EndIf
    $ARRAY = $arTmp
    Return 0
EndFunc ;==>_Array2DDelete

Best Regards BugFix  

Share this post


Link to post
Share on other sites

beautiful, thanks alot!! :)


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites

Just wanted to say it worked perfectly :)

Thanks again,

Kenny


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

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