Sign in to follow this  
Followers 0
Simucal

Quick _arraybinarysearch Question.

3 posts in this topic

#1 ·  Posted (edited)

Alright, when I do a binary search on an array that has the drive letters of the system on it, why does it give me an Error code #2? How is "c:" out of bounds?

$SystemDrives = DriveGetDrive("Fixed")
_ArraySort($SystemDrives)
_ArrayDisplay( $SystemDrives, "sorted" )
$DriveC = _ArrayBinarySearch ($SystemDrives, "c:")
If Not @error Then
   Msgbox(0,'Entry found',' Index:' & $DriveC)
Else
   Msgbox(0,'Entry Not found',' Error:' & @error)
EndIf

Always get the error code 2.

Parameters

$avArray The 1-dimensional sorted array to search on.

$iKey String or number to search for in the array.

$i_Base Optional: Start Array index for sort, normally set to 0 or 1.

Return Value

Success: Returns the key (index of where item is in the array).

Failure: Returns an empty string.

@Error: 0 = No error.

1 = $avArray isn't an array.

2 = $iKey is out of bounds.

3 = If the item wasn't found in the array.

Edited by Simucal

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Skip the first entry of the array because that contains a numeric entry:

#include<array.au3>
$SystemDrives = DriveGetDrive("Fixed")
_ArraySort($SystemDrives,0,1)
_ArrayDisplay( $SystemDrives, "sorted")
$DriveC = _ArrayBinarySearch ($SystemDrives, "c:",1)
If Not @error Then
   Msgbox(0,'Entry found',' Index:' & $DriveC)
Else
   Msgbox(0,'Entry Not found',' Error:' & @error)
EndIf
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Ahhh, gotchya. Thanks a ton JdeB


AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0