lsakizada Posted May 11, 2010 Share Posted May 11, 2010 (edited) Hi,I want to create third array from two unique arrays that not contain the common elements.For exampleDim $aArray_A[3] = ["A","B","C"] Dim $aArray_B[1] = ["A"]The expected results:Dim $aArray_C[2] = ["B","C"]Please do not take an account case sensitive or not sensitiveWhats the best way to do it? Edited May 11, 2010 by lsakizada Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
l3ill Posted May 11, 2010 Share Posted May 11, 2010 Isn't that what _ArrayConcatenate does? never used it..just speculating ;-) My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
JohnOne Posted May 11, 2010 Share Posted May 11, 2010 http://www.autoitscript.com/forum/index.php?showtopic=71035 have a look at this code by monoceres AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 11, 2010 Moderators Share Posted May 11, 2010 billo,Isn't that what _ArrayConcatenate does?_ArrayConcatenate does what it says - it adds the 2 arrays together. lsakizada,Copy the larger array to the array you want to end with. Loop through the smaller array. For each element do an _ArraySearch in the copied array and _ArrayDelete any matches. At the end you have an array holding those elements from the larger array which are not in the smaller. 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...
Spiff59 Posted May 11, 2010 Share Posted May 11, 2010 There are a whole flock of useless _Array...() functions, but nothing that suits your need. I'd think you'd need nested loops to manually compare your arrays and delete matches. Then you could go with an _ArrayConcatenate() and an _ArraySort() if needed. Maybe even throw in an _ArrayUnique() if you're concerned about dupes within a single source array. Link to comment Share on other sites More sharing options...
lsakizada Posted May 11, 2010 Author Share Posted May 11, 2010 I love this forum! 5 minutes and 4 replies !!!! Thank you all guys, the link from JohnOne contain the code and the comments from Melba23 is a short brief of it. Regards. Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
Spiff59 Posted May 11, 2010 Share Posted May 11, 2010 (edited) You might play with this... #include <Array.au3> Global $avArray1[5] = ["Valik", "Holger", "Jon", "Larry", "Jeremy"] Global $avArray2[5] = ["Valik", "Cyberslug", "Nutster", "Tylo", "JdeB"] Global $ylen = UBound($avArray2) - 1 For $x = 0 to UBound($avArray1) - 1 For $y = 0 to $ylen If $avArray1[$x] = $avArray2[$y] Then ExitLoop EndIf Next If $y > $ylen Then _ArrayAdd($avArray2, $avArray1[$x]) Next _ArrayDisplay($avArray2) Whether you need to sort the result at the end, or perform an _ArrayUnique upon $avArray1 prior to combining them would be determined by your requirements. Edit: poop. too slow! Edited May 11, 2010 by Spiff59 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