Jump to content

[SOLVED] _ArrayDelete example not working?


Recommended Posts

Hi all, I have a question about the example in _arrayDelete.

If I run it on the spot with the example file it doesn't delete the row 3 of the array: (image 1)

 

#include <Array.au3>

Local $aArray[5] = [0, 1, 2, 3, 4]

_ArrayDisplay($aArray, "Original")
_ArrayDelete($aArray, 2)
_ArrayDisplay($aArray, "Element 2 deleted")

Local $aArray_Base[25][4]
For $i = 0 To 24
    For $j = 0 To 3
        $aArray_Base[$i][$j] = $i & "-" & $j
    Next
Next

; Single row
$aArray = $aArray_Base
_ArrayDisplay($aArray, "BEFORE deletion")
_ArrayDelete($aArray, 7)
_ArrayDisplay($aArray, "SINGLE ROW deleted")

; Range string
$aArray = $aArray_Base
Local $sRange = "0;11-15;24"
_ArrayDisplay($aArray, "BEFORE deletion")
_ArrayDelete($aArray, $sRange)
ConsoleWrite(" " & @error & @CRLF)
_ArrayDisplay($aArray, "RANGE STRING deleted")

; 1D array
$aArray = $aArray_Base
Local $aDel[4] = [3, 5, 11, 13]
_ArrayDisplay($aArray, "BEFORE deletion")
_ArrayDelete($aArray, $aDel)
_ArrayDisplay($aArray, "RANGE ARRAY deleted")

It should delete the rows number 3, 5, 11 and 13 but the 3rd doesn't get deleted.

Additionaly I've tryied modify the example and it works even worst. The error returns 0. (image 2)

 

Thanks in advance!

arraydel.png

arraydel2.png

Edited by JackER4565
Solved
Link to comment
Share on other sites

25 minutes ago, JackER4565 said:

It should delete the rows number 3, 5, 11 and 13 but the 3rd doesn't get deleted.

When using the $vRange as a 1D array, you have to specify the number of elements to delete in the 0th element of your $vRange array, as stated in the Help file:

$vRange can also be a 1D array listing all rows to be deleted with the count in the [0] element.

Cheers ^_^

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

1 minute ago, FrancescoDiMuro said:

When using the $vRange as a 1D array, you have to specify the number of elements to delete in the 0th element of your $vRange array, as stated in the Help file:

$vRange can also be a 1D array listing all rows to be deleted with the count in the [0] element.

Cheers ^_^

Do'h thanks so much!!

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...