Valnurat Posted June 8, 2016 Posted June 8, 2016 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.
orbs Posted June 8, 2016 Posted June 8, 2016 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 WinPose - simultaneous fluent move and resize 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 Magic Math - a math puzzle Demos: Title Bar Menu - click the window title to pop-up a menu
Valnurat Posted June 8, 2016 Author Posted June 8, 2016 Ok. Thank you. I want to keep array[0] - Array[19] _ArrayDelete($aHit,'20-' & UBound($aHit) - 1) Yours sincerely Kenneth.
jdelaney Posted June 9, 2016 Posted June 9, 2016 (edited) 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 June 9, 2016 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now