Aceguy Posted April 17, 2009 Share Posted April 17, 2009 (edited) #include<array.au3> ;Test to find the difference between the 2 arrays dim $array1[8] = ["a","b","d","f","h","j","k","l"] dim $array2[13] = ["a","b","c","d","e","f","g","h","i","j","k","l","m"] dim $array3[ubound($array2)] dim $total[1] $a=0 ;copy $array2 as i want it kept for $ct=0 to ubound($array2)-1 $array3[$ct]=$array2[$ct] Next ;mark $array3 with a blank array ("") for deletion if found for $c = 0 to UBound($array2)-1 $sea=_ArraySearch($array1,$array2[$c],0,0) if @error=0 then $array3[$c]="" EndIf Next ;delete all "" entries for $d=0 to UBound($array3)-1 if $array3[$d]<>"" Then $total[$a]=$array3[$d] $a+=1 if $d<UBound($array3)-1 then ReDim $total[$a+1] EndIf Next ;display _ArrayDisplay($total) this works for me, anyone know an easier way...... Edited April 17, 2009 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
martin Posted April 17, 2009 Share Posted April 17, 2009 #include<array.au3> ;Test to find the difference between the 2 arrays dim $array1[8] = ["a","b","d","f","h","j","k","l"] dim $array2[13] = ["a","b","c","d","e","f","g","h","i","j","k","l","m"] dim $array3[ubound($array2)] dim $total[1] $a=0 ;copy $array2 as i want it kept for $ct=0 to ubound($array2)-1 $array3[$ct]=$array2[$ct] Next ;mark $array3 with a blank array ("") for deletion if found for $c = 0 to UBound($array2)-1 $sea=_ArraySearch($array1,$array2[$c],0,0) if @error=0 then $array3[$c]="" EndIf Next ;delete all "" entries for $d=0 to UBound($array3)-1 if $array3[$d]<>"" Then $total[$a]=$array3[$d] $a+=1 if $d<UBound($array3)-1 then ReDim $total[$a+1] EndIf Next ;display _ArrayDisplay($total) this works for me, anyone know an easier way...... You can copy an array like this Dim $arrayA[3] = [1,2,3] $CopyA = $arrayA. Your function doesn't find the differences between the 2 arrays; it only finds the values in $array2 which are not in $array1 but there could be values in $array1 which are not in $array2. Perhaps that's what you want but I thought that it was worth saying. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 17, 2009 Share Posted April 17, 2009 (edited) #include<array.au3> ;Test to find the difference between the 2 arrays dim $array1[8] = ["a","b","d","f","h","j","k","l"] dim $array2[13] = ["a","b","c","d","e","f","g","h","i","j","k","l","m"] dim $array3[ubound($array2)] dim $total[1] $a=0 ;copy $array2 as i want it kept for $ct=0 to ubound($array2)-1 $array3[$ct]=$array2[$ct] NextWell, to start with, you don't have to copy an array one element at a time. Just "Dim $array3 = $array2" would have done it. ;mark $array3 with a blank array ("") for deletion if found for $c = 0 to UBound($array2)-1 $sea=_ArraySearch($array1,$array2[$c],0,0) if @error=0 then $array3[$c]="" EndIf Next ;delete all "" entries for $d=0 to UBound($array3)-1 if $array3[$d]<>"" Then $total[$a]=$array3[$d] $a+=1 if $d<UBound($array3)-1 then ReDim $total[$a+1] EndIf Next ;display _ArrayDisplay($total) this works for me, anyone know an easier way...... Why change the element and then go back again to delete it? In fact, why work with $array3 at all? Just loop through the first array checking against the second array, and assembling a delimited string of unique values (diffs). One StringSplit() at the end produce your output array. Edited April 17, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Aceguy Posted April 17, 2009 Author Share Posted April 17, 2009 (edited) thansk for the info guys, i have learnt lots.... #include<array.au3> ;Test to find the difference between the 2 arrays dim $array1[8] = ["a","b","d","f","h","j","k","l"] dim $array2[13] = ["a","b","c","d","e","f","g","h","i","j","k","l","m"] ;mark $array3 with a blank array ("") for deletion if found $array3="" for $c = 0 to UBound($array2)-1 $sea=_ArraySearch($array1,$array2[$c],0,0) if @error=6 then $array3&=$array2[$c]&"," EndIf Next ;reconstruct & display $ss=StringSplit($array3,",") _ArrayDelete($ss,UBound($ss)-1) _ArrayDisplay($ss) Your function doesn't find the differences between the 2 arrays; it only finds the values in $array2 which are not in $array1 but there could be values in $array1 which are not in $array2. Perhaps that's what you want but I thought that it was worth saying. thats the way i wanted it, so thanks for mentionioning. $array2 must remain untouched. they are files in a folder to be processed, and $array1 is the ones that have already been processed at a previous time.... so needed to find the ones that havent been done Ty for all your help tho.... whats the limit for the size of an array..... Edited April 17, 2009 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
BugFix Posted April 17, 2009 Share Posted April 17, 2009 This may be interesting for you: _GetIntersection Best Regards BugFix 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