AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to compare two lists?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
twhyman



Joined: 07 Dec 2005
Posts: 264

PostPosted: Sun May 07, 2006 12:15 pm    Post subject: How to compare two lists? Reply with quote

Hi,

i have two txt files containing file name.

i want to compare them and recive a file containing the differnce.

Code:

Example:

File1.txt       Vs.       File2.txt     =   File3.txt
---------                   ---------         ---------- 
a.jpg                       a.jpg             The Differnce is:
b.jpg                       b.jpg             d.jpg
c.jpg                       c.jpg
d.jpg


there is a script that compars two TXT files but its result is that line 3 wich c.jpg is the differnce, here is the SCRIPT

what i really need is compare content not lines.

how can i fix it?

Thanks
TwhyMan
Back to top
View user's profile Send private message
foom



Joined: 19 Apr 2006
Posts: 386

PostPosted: Sun May 07, 2006 2:48 pm    Post subject: Reply with quote

Does this work for you?
Code:
FileRead, ContentsA, file1.txt
FileRead, ContentsB, file2.txt

Loop, Parse, ContentsA , `n, `r
{
    IfNotInString, ContentsB, %A_LoopField%
        result:=result . A_LoopField . "`n"
}

Loop, Parse, ContentsB , `n, `r
{
    IfNotInString, ContentsA, %A_LoopField%
        result:=result . A_LoopField . "`n"
}
msgbox, % result
Back to top
View user's profile Send private message
twhyman



Joined: 07 Dec 2005
Posts: 264

PostPosted: Sun May 07, 2006 6:18 pm    Post subject: Reply with quote

Yes it does foom,

thanks alot Smile
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue May 09, 2006 9:25 am    Post subject: Reply with quote

foom, this is smart, but with a drawback: if there is SomeFile.jpg in A and File.jpg in B, the second file will be "found" in A.
Of course, if all file names have the same length, or if you are sure this case never happens, you can safely use this script.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
emirvisir



Joined: 07 Dec 2006
Posts: 42

PostPosted: Fri Apr 20, 2007 5:47 pm    Post subject: Reply with quote

does this work the same when the lists are contained in variables?

I want to compare two Winget ControlListHwnd commands, to be able to send events directly to a new control which appears at a given point.
Back to top
View user's profile Send private message
Andi



Joined: 11 Feb 2005
Posts: 157
Location: Germany, Niestetal

PostPosted: Sat Apr 21, 2007 6:51 am    Post subject: Reply with quote

The script compares already two variables ContentsA with
ContentsB Surprised
Back to top
View user's profile Send private message
emirvisir



Joined: 07 Dec 2006
Posts: 42

PostPosted: Sat Apr 21, 2007 11:27 am    Post subject: Reply with quote

heh, I guess I did not read the code too attentively... thanks for pointing that out Embarassed
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group