cal Posted September 28, 2010 Share Posted September 28, 2010 _ArraySearch on a 2D array. The help file says it returns the index of where the value was found. It should return a -1 if not found and set the error code. If found its working as expected, but if not found it sets the error code fine but its returning a 1 instead of a -1. I can work around it now that I know whats going on. Just wondering if this a known issue or perhaps something on my side. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 28, 2010 Moderators Share Posted September 28, 2010 cal,There is nothing in the _ArraySearch code to suggest that it would ever return with @error set and 1 as the return value - all the Return SetError lines use -1. Could you let us see an array which gives you the problem - and the basic code you are using as well, of course. 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...
cal Posted September 28, 2010 Author Share Posted September 28, 2010 Perhaps its on my side. I'll see if I can make up an example and reproduce it. If not, I'll see if I can post part of the original code that has this problem. Link to comment Share on other sites More sharing options...
cal Posted September 28, 2010 Author Share Posted September 28, 2010 Yep. my side. Creating separate code made me realize what I was doing. Test Code below. Note that the error is 6 as it should be. Note that my message boxes are formatted with dashes. Its an expansion from typing mb that I use a lot. Helps detecting beginning and trailing spaces but here it made me think the -1 was a 1. But the true mistake was in my "if" statements. I has assumed that a -1 would not trigger the "if" statements to run. It does. If I change it to put the "> 0 " part in like the second "if" statement then it works as expected. I modified the original codes "IF" statements and it now works. expandcollapse popup$ver = 'ver 1w' #Tidy_Parameters = /Skip_EndRegion_Comment If Not @Compiled Then Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info Opt("MouseCoordMode", 0) ;1=absolute, 0=relative Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced FileChangeDir(@ScriptDir) #Include <Array.au3> ;~ #include <_array_display_expand.au3> ; ensure this copy is the running one. $g_szVersion = "test Script" If WinExists($g_szVersion) Then WinClose($g_szVersion) AutoItWinSetTitle($g_szVersion) HotKeySet("{ESC}", "Terminate") Func Terminate() Exit 0 EndFunc ;==>Terminate Dim $a[2][2] $a[0][0] = 'up left' $a[0][1] = 'up right' $a[1][0] = 'bottom left' $a[1][1] = 'bottom right' ;~ _ArrayDisplayExpanded($a ,'Line ' & @ScriptLineNumber & ' --- ' & '') _ArrayDisplay($a) $t = _ArraySearch($a, 'site/down', 0, 0, 0, 1, 1, 0) MsgBox(0,'Line ' & @ScriptLineNumber, '---' & @error & '---') MsgBox(0,'Line ' & @ScriptLineNumber, '---' & $t & '---') If _ArraySearch($a, 'site/down', 0, 0, 0, 1, 1, 0) then MsgBox(0,'Line ' & @ScriptLineNumber, '--- found ---') If _ArraySearch($a, 'site/down', 0, 0, 0, 1, 1, 0) > 0 then MsgBox(0,'Line ' & @ScriptLineNumber, '--- found take two ---') 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