Jump to content

Problem with _ArrayDelete()


Recommended Posts

https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayDelete.htm

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

...

; 1D array
$aArray = $aArray_Base
Local $aDel[4] = [3, 5, 11, 13]                      ;Test 1 Default<--- it fails to Delete row 3
Local $aDel[5] = [0, 3, 5, 11, 13]                   ;Test 2 Workaround<--- it fails to Delete row 0, 5, 11 & 13
_ArrayDisplay($aArray, "BEFORE deletion")
_ArrayDelete($aArray, $aDel)
_ArrayDisplay($aArray, "RANGE ARRAY deleted")

here is a section of the sample code copied from the link above, where it fails to delete 1st indicated row in $vRange. In this case it fails to delete indicated row #3 in $vRange [3, 5, 11, 13it does delete the following row #5, 11 and 13 fine. Tested with my data and that is how i found out the hard way - this messed up my project the past couple of weeks without realizing it until now. a simple single row 3 in $vRange _ArrayDelete($aArray, 3) wihout a problem

because what demonstrated above skips the 1st row in  $vRange , I thought I could get away with a workaround by insert a row #0 in $vRange as [0, 3, 5, 11, 13], with an understand that I would skip 1st row in $vRange but no. It does skip 1st row in $vRange and delete row #3 in $vRange but fail to delete the following rows 5, 11 & 13

any thoughts?

Edited by Melba23
Not a bug - PC-chair interface problem!
Link to comment
Share on other sites

Quote

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

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

thanks, saw that but somehow it didn't click. without realizing that, my workaround almost work except, it simply need the correct count inserted (:

Now I wish _ArrayFindAll() returns w/count in 1st element b/c that's what i'm relying on.

thanks again

Edited by zeenmakr
Link to comment
Share on other sites

the helpfile also states

Quote

$vRange can be a string containing the rows which are to be deleted. It can be a single number or a range ... multiple items are separated by a semi-colon (;)

so:

local $aArray[6] = [1,2,3,2,5,2]
$aDel = _ArrayFindAll($aArray , 2)
_ArrayDelete($aArray , _ArrayToString($aDel , ";"))
_ArrayDisplay($aArray)

or reduced

local $aArray[6] = [1,2,3,2,5,2]
_ArrayDelete($aArray , _ArrayToString(_ArrayFindAll($aArray , 2) , ";"))
_ArrayDisplay($aArray)


 

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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