RE: Compare two text streams



I kind of understand what you mean, but I am not 100%. Can you elaborate with
code.. Sorry, I am not great with the "concept" part of Vbscript. It is still
very confusing to me...

"urkec" wrote:

I think it's because when your outer loop executes for the second time,
objTextStream2 is already at the end of stream, so the inner loop doesn't
execute. You could move objTextStream2 = objFSO.OpenTextFile... inside the
outer loop to reopen it each time the loop executes. Or you could use str =
objTextStream2.RadAll and InStr to check if the line read from the first file
exists in the second file.

--
urkec


"Shadrach" wrote:

Please help me with this code.. Here is the situation. I need to compare 2
files with mac addresses. I will code in the match and don't match stuff..
but I need to ID (true,false) if a mac address is in one file but not the
other. Please tell me what is wrong in this code.. It only does the first
line of file one.

On Error Resume Next

'Initialize global constants and variables.
Const FOR_READING = 1
strHostFile1 = "mac1.txt"
strHostFile2 = "mac2.txt"
'******************************************************************************

'Read mac address file 1 for comparison.
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strHostFile1) Then
Set objTextStream1 = objFSO.OpenTextFile(strHostFile1, FOR_READING)
Else
WScript.Echo "Input file " & strHostFile1 & " Not found."
WScript.Quit
End If
'******************************************************************************

'Read mac address file 2 for comparison.
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strHostFile2) Then
Set objTextStream2 = objFSO.OpenTextFile(strHostFile2, FOR_READING)
Else
WScript.Echo "Input file " & strHostFile2 & " not found."
WScript.Quit
End If


'Loop through list of computers and perform tasks on each.
Do Until objTextStream1.AtEndOfStream
g_strComputer1 = objTextStream1.ReadLine
Do Until objTextStream2.AtEndOfStream
g_strComputer2 = objTextStream2.ReadLine
If (StrComp(g_strComputer1, g_strComputer2)) = 0 Then
WScript.Echo "Match: " & g_strComputer1 & " = " & g_strComputer2
Else
WScript.Echo "No Match: " & g_strComputer1 & " = " & g_strComputer2
End If
Loop

Loop
objTextStream1.Close

.



Relevant Pages

  • RE: Compare two text streams
    ... I think it's because when your outer loop executes for the second time, ... files with mac addresses. ... Set objFSO = CreateObject ... Set objTextStream2 = objFSO.OpenTextFile ...
    (microsoft.public.scripting.vbscript)
  • RE: Compare two text streams
    ... "urkec" wrote: ... 'Loop through list of computers and perform tasks on each. ... files with mac addresses. ... Set objFSO = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • RE: Compare two text streams
    ... 'Loop through list of computers and perform tasks on each. ... "urkec" wrote: ... files with mac addresses. ... Set objFSO = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: Ruby is Running Slow on Mac OS X
    ... My mac is new, ... I have it on a loop, and on average it took 10-30 ... One thing I observed on upgrading to Leopard (see ... use WPA instead of WEP encryption. ...
    (comp.lang.ruby)
  • Odd ksh problem
    ... but it is blowing up on my Mac. ... and fourth fields and pass the last 200 lines on to a while loop. ... Originally it was an awk script ... ksh ought to work if I ...
    (comp.sys.mac.programmer.misc)

Loading