MaximusCZ Posted November 7 Share Posted November 7 Can someone explain why is the 96 not found? Says Error code 2, which is value outside of array min/max, but clearly is not. Column 0 is sorted, ideally I want to ignore all other columns, but the default values for optional parameters for _ArrayBinarySearch is 0. I think this should be "-1", because I dont want to search every column when specifying 0 in $iColumn. I want to ONLY search column 0, but I guess setting Column 0 just makes it search every column instead? Link to comment Share on other sites More sharing options...
Solution Nine Posted November 7 Solution Share Posted November 7 Maybe because the value included in the array are strings not numbers ? ps. please provide a runable script as you should know by now. A picture doesn't help any bit. Try to make it easy for us to help you pixelsearch 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
pixelsearch Posted November 7 Share Posted November 7 35 minutes ago, Nine said: Maybe because the value included in the array are strings not numbers ? ...and if $vValue (2nd parameter of _ArrayBinarySearch) is a string too, then we got OP's error 2, for example : #include <Array.au3> #include <MsgBoxConstants.au3> Local $avArray[3] $avArray[0] = "64" $avArray[1] = "96" $avArray[2] = "150" _ArrayDisplay($avArray, "$avArray ") Local $iKeyIndex = _ArrayBinarySearch($avArray, "96") If Not @error Then MsgBox($MB_TOPMOST, 'Entry found', ' Index: ' & $iKeyIndex) Else MsgBox($MB_TOPMOST, 'Entry Not found', ' Error: ' & @error) EndIf I just tested the 4 possible combinations : * Strings in array + String in $vValue => error 2 (that's the example above) * Strings in array + Number in $vValue : found (no error) * Numbers in array + String in $vValue : found (no error) * Numbers in array + Number in $vValue : found (no error) 3 hours ago, MaximusCZ said: I guess setting Column 0 just makes it search every column instead? I don't think so, _ArrayBinarySearch never searches in several columns. Column parameter set to 0 (last optional parameter of _ArrayBinarySearch) will search only in column 0 (according to the code found in Array.au3) Link to comment Share on other sites More sharing options...
MaximusCZ Posted November 7 Author Share Posted November 7 (edited) 18 hours ago, Nine said: Maybe because the value included in the array are strings not numbers ? Oh my god, now that wouldn't occur to me in a long while, that must be it. Funny how at least one, search term or array element, must be Number, but not both. 17 hours ago, pixelsearch said: I don't think so, _ArrayBinarySearch never searches in several columns. Column parameter set to 0 (last optional parameter of _ArrayBinarySearch) will search only in column 0 (according to the code found in Array.au3) Ah, then I guess it's just not consistent with other functions that default to -1, but I am okay with that. Thank you both! Edit: Yes, specifying the $time to Number($time) started returning search results OK! Edited November 8 by MaximusCZ 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