kor Posted November 19, 2012 Share Posted November 19, 2012 (edited) I have 6 inputs I'm reading in using a loop. For $i = 1 To UBound($aInput) - 1 $aRead[$i] = GUICtrlRead($aControls[$aInput[$i]]) Next without posting the entire code just assume the above loop already works. It gives me all 6 inputs. What I need to do is then compare each input with every other input. So for example if Input1="test" and Input2="test" I need throw an error. Basically all 6 inputs must be unique and none of them can contain the value of any of the others. Trying to figure out how I can write that kind of statement. Do I need to do a loop within a loop or where might I begin? EDIT: forgot to mention that technically the inputs can be null. So if input2 and input3 are both null that is fine as long as if they did have values they are not the same. Edited November 19, 2012 by kor Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 19, 2012 Moderators Share Posted November 19, 2012 Hi, kor. Have you tried just using _ArrayUnique, to have the duplicates stripped out for you, rather than trying to loop through them all? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
kor Posted November 19, 2012 Author Share Posted November 19, 2012 I looked at ArrayUnique but I don't actually need the unique values, I need to know if the values are repeated. ArrayUnique doesn't look like it offers any way to return a value that would tell me that it has stripped values from the array because they are not unique. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 19, 2012 Moderators Share Posted November 19, 2012 kor,Just compare the sizes of the arrays with UBound after you have run _ArrayUnique - the same size means all original items were unique, different sizes means you had some matches. 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...
kor Posted November 19, 2012 Author Share Posted November 19, 2012 (edited) I can't just know if the arrays are different sizes. I need to know which input is the same as the other If Input 2 and Input 5 are the same value I need to know. It's not as simple as just knowing if all values are unique or not, if they are not unique I need to know and throw an error for the input that is duplicated. Edited November 19, 2012 by kor Link to comment Share on other sites More sharing options...
jdelaney Posted November 19, 2012 Share Posted November 19, 2012 (edited) you can make a temp array, that is equal to your control array, and then do: redim $tempArray[7] or 6, depending on if 0 based Edited November 19, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
kor Posted November 20, 2012 Author Share Posted November 20, 2012 something like this? Local $aData[6] = ["a", "b", "c", "d", "e", "f"] Local $aNew[6] = ["a", "i", "j", "k", "l", ","] For $i = 0 To UBound($aData) - 1 For $n = 0 To UBound($aNew) - 1 If $aData[$i] = $aNew[$n] Then ConsoleWrite("$aNew has duplicate in index " & $n + 1 & @CR) Next Next Link to comment Share on other sites More sharing options...
kylomas Posted November 20, 2012 Share Posted November 20, 2012 Kor, Or something like this #include <array.au3> local $aInputs[5] = ['tom','john','george','alex','john'] local $st = timerinit() local $sDiff = _FindDups($aInputs) consolewrite('time to run func = ' & round(timerdiff($st)/1000,4) & @lf) func _FindDups($array) for $i = 0 to ubound($array) - 1 if isdeclared('s' & $array[$i]) then consolewrite('Dup found at element = ' & $i & ' dup value = ' & $array[$i] & @lf) else assign('s' & $array[$i],1) endif Next endfunc kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kor Posted November 20, 2012 Author Share Posted November 20, 2012 @kylomas, that works great! Is there a way to also know the original element that the duplicate is from? IE, you use $i as the location of where the duplicate exists, but is there a way to determine at what index the original is from (or at least the first usage of it in the index?) IE, if elements 2 and 5 are the same, then $i would be 5... but is there a way to get the index of element 2? Link to comment Share on other sites More sharing options...
MilesAhead Posted November 20, 2012 Share Posted November 20, 2012 Seems to me you already have it in post #7 Just show both loop indexes plus one, and if you want the values, in the output display. Why only show one index? My Freeware Page Link to comment Share on other sites More sharing options...
kylomas Posted November 20, 2012 Share Posted November 20, 2012 Kor, Yes. I adapted this from some really slick code that spiff59 posted sometime ago dealing with a similar task. I am not at a real machine, however, so cannot reference that code and am kind of pressed for time. Take the code that I posted apart and I'm sure yo can figure it out. Good Luck, kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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