Jump to content

Deleting rows in an Array


Recommended Posts

I have an array with 40 numbers.

I want to have the top 20 numbers and delete the rest.

I looked at _ArrayDelete example:

; 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")

Så I was thinking I could do this:

_ArrayDelete($aArray, '0;19')

But that does not give me want I want.

How can I keep my top 20 numbers and delete the rest?

Yours sincerely

Kenneth.

Link to comment
Share on other sites

the range is defined by hyphen, not semicolon. use "0-19" to remove lines 0 to 19, not "0;19".

BTW you are not clear if you want to keep the first 20 or the last 20 rows.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Or just redim to the bounds you want.  Would work in your situation when you are just truncating from the UBound towards 0.

ReDim $aHit[20]

 

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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

×
×
  • Create New...