Chimaera Posted June 3, 2015 Share Posted June 3, 2015 (edited) Ive got an array which is 186 elements then i add another array of 48 or so to it, now the count stays at 186 butIf there is an item after the 186 does it get missed because the cycle through the array stops at 186?How do i reset the number to be accurate if thats the case?I made a small reproducer to show it #include <Array.au3> $sRemoveServices = 'AeLookupSvc|ALG|AppHostSvc' Global $aRemoveServices = StringSplit($sRemoveServices, "|") _ArrayDisplay($aRemoveServices, 'Initial Services') $sServiceTotalArray = 'AntiVirService|AntiVirSchedulerService' Global $aServiceTotalArray= StringSplit($sServiceTotalArray, "|") Local $aServiceArrayAdd = _ArrayAdd($aRemoveServices, $aServiceTotalArray, '0', '|') _ArraySort($aRemoveServices) ; sort them into numerical _ArrayDelete($aRemoveServices, 0) ; for some reason it picks up a another index after the add so i delete it ;~ ReDim $aRemoveServices _ArrayDisplay($aRemoveServices, 'Total Services')Now i started looking at redim but couldnt figure out what element to give as i dont know the last element Edited June 3, 2015 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 3, 2015 Moderators Share Posted June 3, 2015 Chimaera,No, the actual value in the [0] element has no effect on the rest of the array. It is just used as a shortcut count by some AutoIt functions and does not need to be accurate - if you think about it, how would AutoIt even know that it was a count? If you need to know the number of elements in an array, just use UBound.M23 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...
Chimaera Posted June 3, 2015 Author Share Posted June 3, 2015 Ok im finding its not picking up some that are in that section after the 186 so ill go and recheck to see if i can find any thing else that might be causing it.Many thanks If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
iamtheky Posted June 3, 2015 Share Posted June 3, 2015 if you wanted to keep it, you have all the info prior to the _arrayadd.$aRemoveServices[0] = ubound($aRemoveServices) + ubound($aServiceTotalArray)i think that number could also be used for a redim, but that would seem unnecessary since _arrayadd did that. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 3, 2015 Moderators Share Posted June 3, 2015 Chimaera,If you are coding the loop like this:For $i = 1 To $aArray[0]then you do need an accurate count - if not then the loop will stop too early or you will get an overrun error.If you do not know that the [0] element count is accurate (or indeed you do not have one) then do it like this:For $i = 1 To UBound($aArray) - 1Clear now?M23 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...
Chimaera Posted June 3, 2015 Author Share Posted June 3, 2015 (edited) Well spotted Melba23 that indeed is the problem and its working again many thanks to all Edited June 3, 2015 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Chimaera Posted June 6, 2015 Author Share Posted June 6, 2015 (edited) Still working with this i decided to add a progress bar as it passes through the arraygot the single array ones working but the joining arrays together for a different task is making me crossLocal $aServiceStopAdd0 = _ArrayAdd($aServiceStopArray, $sServiceManualList) Local $aServiceStopAdd1 = _ArrayAdd($aServiceStopArray, $sServiceDisabledList) _ArraySort($aServiceStopArray) _ArrayDisplay($aServiceStopArray, 'Services To Stop') $sStopCount = Round( _ArrayMax($aServiceStopArray) /3, 0) ConsoleWrite('Stop Count = ' & $sStopCount & @CRLF)This how im joining them but it has no 0 (number) section with the count so the arraymax doesnt have a number to work withI tried boththose suggestion like Global $aServiceStopArray[0] = UBound($aServiceDisabledArray) + UBound($aServiceManualArray) ;~ Local $aServiceStopAdd0 = _ArrayAdd($aServiceStopArray, $sServiceManualList) ;~ Local $aServiceStopAdd1 = _ArrayAdd($aServiceStopArray, $sServiceDisabledList) _ArraySort($aServiceStopArray) _ArrayDisplay($aServiceStopArray, 'Services To Stop') $sStopCount = Round( _ArrayMax($aServiceStopArray) /3, 0) ConsoleWrite('Stop Count = ' & $sStopCount & @CRLF)but it gives me an error like this: error: Statement cannot be just an expression.Global $aServiceStopArray[0] = UBoundAny suggestions? Edited June 6, 2015 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Malkey Posted June 6, 2015 Share Posted June 6, 2015 _ArrayAdd() does not return a third array. Also see AutoIt help file.#include <Array.au3> $sRemoveServices = 'AeLookupSvc|ALG|AppHostSvc' Global $aArray1 = StringSplit($sRemoveServices, "|", 2) ; $STR_NOCOUNT (2) = disable the return count in the first element - effectively makes the array 0-based (must use UBound() to get the size of the array in this case). _ArrayDisplay($aArray1, '0-based Array1') $sServiceTotalArray = 'AntiVirService|AntiVirSchedulerService' Global $aArray2 = StringSplit($sServiceTotalArray, "|", 2) ; $STR_NOCOUNT (2) = disable the return count in the first element - effectively makes the array 0-based (must use UBound() to get the size of the array in this case). _ArrayDisplay($aArray2, '0-based Array2') _ArrayAdd($aArray1, $aArray2) ; The 3rd parameter of _ArrayAdd, $iStart, [optional] Column in which addition is to begin (2D array only). See _ArrayConcatenate() for a $iStart parameter. _ArrayDisplay($aArray1, '0-based ($aArray1 + Array2)') _ArrayInsert($aArray1, 0, UBound($aArray1)) ; Convert $aArray1 from a 0-based array into a 1-based array. _ArrayDisplay($aArray1, '1-based Array') Link to comment Share on other sites More sharing options...
Chimaera Posted June 7, 2015 Author Share Posted June 7, 2015 Took me a few before i twigged you have to remove the counts before you can create the count thxBack to work... If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() 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