Neno Posted May 3, 2010 Share Posted May 3, 2010 (edited) Hello! First, thanks for taking the time to help me out. I'd like to tell you how much autoit has helped me out with redundant chores on my computer. Unfortunately, I ran into a slight issue using _ArrayMinIndex. My entire program is about 700 lines long so I won't bore you with all the details, but basically, I have the program look at a set of downloads (Indicated by blue bars) and calculate the percentage of completion. After which, it returns the lowest value to me. That's all well and good, and the pixelsearches in the following function work great. However, when I add the If @error = 0 Then $download_array[$i] = 100 ; percentage that is... It fails. I do not understand why. (I put 100 percent so that it will not be the min, even if the download doesn't really exist). Without further delay, here is my function: Func dl_findlowest() PixelSearch($download_pos[$i][0] + 1, $download_pos[$i][1] + 1, $download_pos[$i][0] + 2, $download_pos[$i][1] + 2, 0xFFFFFF, 40) If @error = 1 Then PixelSearch($download_pos[$i][0] + 0, $download_pos[$i][1] + 1, $download_pos[$i][0] + 2, $download_pos[$i][3] + 25, 0x051275, 20) If Not @error Then $download_pixel = PixelSearch($download_pos[$i][0] + 1, $download_pos[$i][1] + 1, $download_pos[$i][2] - 1, $download_pos[$i][1] + 2, 0xFFFFFF, 40) If Not @error Then $download_perc =100-(($download_pixel[0]-($download_pos[$i][2]-1))/(($download_pos[$i][0]+1)-($download_pos[$i][2]-1)))*100 If $download_perc = 0 Then $download_perc = 100 EndIf $download_array[$i] = $download_perc EndIf EndIf ElseIf @error = 0 Then $download_array[$i] = 100 ;<<======= this causes issues EndIf If $i = $NumOfDownloads Then $z_pass1 = ((_ArrayMinIndex($download_array, 1, 0, $NumOfDownloads))-1); the -1 because, for some reason, they add 1 to the index (0 = 1) ToolTip("ArrayMinIndex : " & $z_pass1, 500, 500) If $z_pass1 >= 0 Then $z_pass2 = $download_array[$z_pass1] MsgBox(0,"Downloads", "Lowest percentage is: " & $z_pass2) EndIf EndIf EndFunc Edited May 3, 2010 by Neno Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 3, 2010 Moderators Share Posted May 3, 2010 Neno,Welcome to the AutoIt forum. It failsHow?Does the script stop completely with an error? If so, what error are you getting? Look in the bottom pane of SciTE to find out.Or is it an internal function error? If so , how dioes it manifest itself?What statements are you using to declare the $download_pos and $download_array arrays?Sorry for all the questions, but there is not a lot to go on at the moment. 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...
Neno Posted May 3, 2010 Author Share Posted May 3, 2010 Ehhhhhhhhhhhh..... After I posted that (In frustration) I looked at it and looked at it, then I finally realized what an idiot I really was.Initial testing with autoit's _ArrayMinIndex led me to believe that it was in fact starting at 1 rather than 0, so I was subtracting 1, then throwing it into another array as a subscript variable, causing a crash... *sigh* and that kept me stumped for 8 hours, because egotistically I guess I thought "I couldn't be wrong, it must be the programming language!"I'm going to go jump off a bridge now, yeah. Thanks for the response.Neno,Welcome to the AutoIt forum. How?Does the script stop completely with an error? If so, what error are you getting? Look in the bottom pane of SciTE to find out.Or is it an internal function error? If so , how dioes it manifest itself?What statements are you using to declare the $download_pos and $download_array arrays?Sorry for all the questions, but there is not a lot to go on at the moment. M23 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 3, 2010 Moderators Share Posted May 3, 2010 Neno,Glad you got it sorted. By the way, when you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. 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...
JohnOne Posted May 3, 2010 Share Posted May 3, 2010 If your arrays are indeed declared, then peraps the only thing you are doing wrong is not passing the value of $i to the function. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Neno Posted May 3, 2010 Author Share Posted May 3, 2010 Well, here was/is my main issue with autoit's _ArrayMinIndex function: If the array is not yet full (Meaning there are void entries in some of the array), the function returns an index for that void entry, rather than an error. Perhaps this is something the developers would like to add to the function as an error return. Here is the code change I made to Array.au3; Search If $iCompNumeric Then For $i = $iStart To $iEnd If $avArray[$i] = Chr(0) Then Return SetError(4, 0, -1) If Number($avArray[$iMinIndex]) > Number($avArray[$i]) Then $iMinIndex = $i Next Else For $i = $iStart To $iEnd If $avArray[$i] = Chr(0) Then Return SetError(4, 0, -1) If $avArray[$iMinIndex] > $avArray[$i] Then $iMinIndex = $i Next EndIf Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 3, 2010 Moderators Share Posted May 3, 2010 Neno,There is no need to alter the UDF - just use the $iStart and $iEnd parameters to limit the elements involved. 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...
Neno Posted May 3, 2010 Author Share Posted May 3, 2010 (edited) Neno,There is no need to alter the UDF - just use the $iStart and $iEnd parameters to limit the elements involved. M23Not a valid solution if there are void entries within the array, not out of bounds.Edit: I threw my solution up on the bugtracker - Ehhh, If they deem it worthy fine, but I could see reasons for intentionally leaving it out. Edited May 3, 2010 by Neno Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 3, 2010 Moderators Share Posted May 3, 2010 Neno,Not a valid solution if there are void entries within the arrayA perfectly valid solution if you count the actual entries in the array, or only expand your array to fit the number of actual entries.As we often say, AutoIt cannot read your mind, you have to tell it what you want it to do. 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...
GEOSoft Posted May 3, 2010 Share Posted May 3, 2010 Neno,A perfectly valid solution if you count the actual entries in the array, or only expand your array to fit the number of actual entries.As we often say, AutoIt cannot read your mind, you have to tell it what you want it to do. M23Blame it on Valik. he hasn't done a damn thing with the DoMyThinkingForMe() function yet. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Neno Posted May 3, 2010 Author Share Posted May 3, 2010 (edited) Yeah, no... I get what it is you're saying, but here's the dynamic of things:I have a variable $i, that is a global variable. This variable runs the main program loop, it also gets used as the index for the array I'm using in the first post. The problem is that even though I tell the array to If $i = $NumOfDownloads- (wait until it's gone around once before finding the min) It doesn't. I do not know why is doesn't, sequentially and logically it makes sense, but... It doesn't.I needed to throw the error because it is a valid bound most of the time.Hopefully that's clearer.EDIT:::New code would read as follows>>Func dl_findlowest() ;;;;<===== START SOME PSEUDO CODE ======>;;;; If -some perimeter- Then $download_array[$i] = -some var- ;;;;<===== END SOME PSEUDO CODE ======>;;;; ElseIf @error = 0 Then $download_array[$i] = 100 EndIf $z_pass1 = (_ArrayMinIndex($download_array, 1, 0, $NumOfDownloads)) If Not @error Then $z_pass2 = $download_array[$z_pass1] MsgBox(0,"Downloads", "Lowest percentage is: " & $z_pass2) EndIf EndFunc(with my udf change)Rather than:If $i = $NumOfDownloads Then $z_pass1 = (_ArrayMinIndex($download_array, 1, 0, $NumOfDownloads)) If $z_pass1 >= 0 Then $z_pass2 = $download_array[$z_pass1] MsgBox(0,"Downloads", "Lowest percentage is: " & $z_pass2) EndIf EndIfAs you can see they should both work equally, but, the latter does not work -all- the time. Edited May 3, 2010 by Neno 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