Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Loop terminates...

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,47728
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Loop terminates...
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Loop terminates... - 5/30/2007 3:54:28 AM   
  danielc

 

Posts: 10
Score: 0
Joined: 3/2/2007
Status: offline
Hello folks,

I am attempting to compare two files.  If the lines match in the file then it writes the match to another file.  But that doesn't work.  If I change the variable 'mytag' to True then I only get one line written to the file and then quits.  What am I doing wrong?

My code is as follows:

Set objFSO = CreateObject("Scripting.FileSystemObject")

Const ForReading = 1

File1 = "C:\Idlink.txt"
File2 = "C:\photo.txt"
wfile = "C:\compdfile.txt"

Set aFile = objFSO.GetFile(File1)
Set aaFile = aFile.OpenAsTextStream(1,-2)
Set bFile = objFSO.GetFile(File2)
Set bbFile = bFile.OpenAsTextStream(1, -2)
Set cFile = objFSO.OpenTextFile(wfile, 8, True)

Do Until aaFile.AtEndOfStream
   line1 = aaFile.ReadLine
Loop

mytag = False

Do Until bbFile.AtEndOfStream
   line2 = bbFile.ReadLine
       If line2 = line1 Then
           myTag = True
           Exit Do
       End If
Loop

If myTag = True Then
   cfile.WriteLine line1
End If

aaFile.Close
bbFile.Close

MsgBox "Complete"

Thanks in advance for all your help,

Dan
 
 
Post #: 1
 
 RE: Loop terminates... - 5/30/2007 5:15:39 AM   
  dm_4ever


Posts: 2723
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
This link might help: http://www.microsoft.com/technet/scriptcenter/resources/qanda/may07/hey0524.mspx

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to danielc)
 
 
Post #: 2
 
 RE: Loop terminates... - 5/30/2007 7:02:31 AM   
  danielc

 

Posts: 10
Score: 0
Joined: 3/2/2007
Status: offline
Thank you dm_4ever....  The article did it...

Dan

(in reply to danielc)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Loop terminates... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts