agreiner Posted September 23, 2011 Share Posted September 23, 2011 I have an array ($variables), which has 2 dimensions (0 = name, 1 = value). I am trying to search the array to return the value for a given name. I know that I missing something very simple, yet I have no idea what it is. _ArraySearch($variables,$name,0,0,0,0,0,0) When I try to run this, I get: ERROR: _ArraySearch() previously called with expression on Const ByRef param(s). Can someone point me in the right direction? Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 23, 2011 Moderators Share Posted September 23, 2011 (edited) agreiner,Welcome to the AutoIt forum. Please post all of your script - there is something wrong with the way you have declared $variables and/or $name by the look of it. M23Edit: And it looks as is you have not set the $iSubItem parameter correctly if you are looking for the second column. P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. Edited September 23, 2011 by Melba23 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...
agreiner Posted September 23, 2011 Author Share Posted September 23, 2011 Unfortunately, I am not allowed to post all of my code (non-disclose agreement); however, I will work on extracting the important bits and see if I can reproduce the issue (that way I can post it, without violating my non-disclose). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 23, 2011 Moderators Share Posted September 23, 2011 agreiner, Fine - but we need some working(ish) code which demonstrates the same problem. 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...
agreiner Posted September 23, 2011 Author Share Posted September 23, 2011 (edited) Melba, Thanks for the help. You resolved my issue with: there is something wrong with the way you have declared $variables and/or $name by the look of it. While attempting to reproduce this issue, I realized that I had declared $variables as Global, then tried to declare it again in the Local scope, later in the script. This code works: #include <Array.au3> ;Create the XML Object $o = ObjCreate("Msxml2.DOMDocument") $o.load("C:\Documents and Settings\agreiner\Desktop\forumexample.xml") $o.setProperty("SelectionLanguage", "XPath") $oVariables = $o.selectNodes("//test/variables/variable") ;Count the variables $varcount = 0 For $oVariable In $oVariables $varcount+=1 Next ;Declare variables array Global $variables[$varcount][2] ;populate the variables array $i = 0 For $oVariable In $oVariables $variables[$i][0] = _NodeGetValue($oVariable.attributes.getNamedItem("name")) $variables[$i][1] = _NodeGetValue($oVariable.attributes.getNamedItem("value")) $i+=1 Next ;sort the array alphabetically by variable name (not needed) ;_ArraySort($variables,0,0,0,0) MsgBox(0,"Var1",VariableFindValue("Var1")) Func VariableFindValue($name) $check = _ArraySearch($variables,$name,0,0,0,0,1,0) If $check < 0 Then Return @error EndIf Return $variables[$check][1] EndFunc Func _NodeGetValue(Const $oNode, $vDefault = "") If Not IsObj($oNode) Then Return SetError(1, 0, $vDefault) Return $oNode.value EndFunc Edit: I guess an xml snippet may be useful as well: <?xml version='1.0' encoding='UTF-8'?> <test> <variables> <variable name="var3" value="0"/> <variable name="var2" value="2"/> <variable name="var1" value="8"/> <variable name="var5" value="5"/> <variable name="var4" value="6"/> </variables> </test> Edited September 23, 2011 by agreiner Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 23, 2011 Moderators Share Posted September 23, 2011 agreiner, Nice to see the remote debugging skills are still up to scratch! 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...
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