caramen Posted December 23, 2020 Share Posted December 23, 2020 (edited) Hello guy. When I delete rows from an array. I come into a problem I never had. How to do something like that without getting stuck in the script because of : incorrect number of subscripts or subscript dimension range exceeded Here is what I did. But.. I know what is the problem I don't know how or what to use to get out from my error. If WinActive ("Tableau de bord Helpdesk") And $SecuAntiFlood > 500 Then $SecuAntiFlood = 0 Sleep (200) Send ("^a") Sleep (200) Send ("^c") MouseClick ( "left" , 1600 , 525 , 1 , 10 ) $iResultsArray = StringSplit ( ClipGet() , @CRLF ) $iRows = UBound ($iResultsArray) $iRows -= 1 ConsoleWrite ($iRows&@CRLF) _ArrayDisplay ($iResultsArray) For $i = 0 To $iRows Step 1 ConsoleWrite ($i&@CRLF) If $iResultsArray[$i] = "" Or $iResultsArray[$i] = " " Then _ArrayDelete ( $iResultsArray , $i ) $i -= 1 EndIf Next _ArrayDisplay ($iResultsArray) EndIf So I have 151 rows. I want to remove all blank rows. To reduce the amount of rows. But If I delete rows from my array of course the number of subscripts will be reduced and my for loop is going to have a number larger than my array rows. I tried to play with $iRows... but it does not effect the for loop if $iRows is called before the number won't change for the loop from what I understand. How to do please guys ? This is a reproducer that demonstrate my error so don't be rude with the code structure. Edited December 23, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 23, 2020 Moderators Share Posted December 23, 2020 caramen, Start from the bottom and work up: For $i = $iRows To 0 Step -1 That way you never try to access a non-existent row. M23 JockoDundee and caramen 2 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
caramen Posted December 23, 2020 Author Share Posted December 23, 2020 (edited) oh ... simple as that xD... Ok trying rn... It work Thanks M23 like always Happy Christmas. Edited December 23, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
caramen Posted December 23, 2020 Author Share Posted December 23, 2020 (edited) @Melba23 I don't get it. My return console write isn't expected : If WinActive ("Tableau de bord Helpdesk") And $SecuAntiFlood > 500 Then $SecuAntiFlood = 0 Sleep (200) Send ("^a") Sleep (200) Send ("^c") MouseClick ( "left" , 1600 , 525 , 1 , 10 ) $iResultsArray = StringSplit ( ClipGet() , @CRLF ) $iRows = UBound ($iResultsArray) $iRows -= 1 ConsoleWrite ("$iRows = "&$iRows&@CRLF) _ArrayDisplay ($iResultsArray) For $i = $iRows To 0 ConsoleWrite ($i&@CRLF) ConsoleWrite ("Array 8"&@CRLF&$iResultsArray[8]&@CRLF) If $iResultsArray[$i] = "" Or $iResultsArray[$i] = " " Or $iResultsArray[$i] = @CRLF Then _ArrayDelete ( $iResultsArray , $i ) $i -= 1 ContinueLoop EndIf Next ConsoleWrite ("$iRows After loop = "&$iRows&@CRLF) _ArrayDisplay ($iResultsArray) EndIf >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\caram\OneDrive\Autoit\Projet Menu contextuel\Menu contextuel 7.0\Final\Menu contextuel 7.6.2.au3" $iRows = 151 $iRows After loop = 151 +>13:44:18 AutoIt3.exe ended.rc:0 151 = $iRows It is like $iRows = 0 -.- Edited December 23, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
caramen Posted December 23, 2020 Author Share Posted December 23, 2020 Arggggg I had to use a negative step. For $i = $iRows To 0 Step -1 Thanks ^^ My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
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