Jump to content

Read contents of one file to search another file


Guest jhtech
 Share

Recommended Posts

Guest jhtech

I'm working on a script to read each line from a text file and use that line to search another text file for the instance from the first text file. I'm doing a directory listing of two folders and creating the text files. Here is my code that I'm working with.

$folder = "D:\iehotfix\rtmgdr"

$OutnameHF = "D:\iehotfix.txt"

$OutnameSys32 = "D:\system32.txt"

#include <file.au3>

Dim $test

_FileReadToArray($OutnameSys32, $test)

$afile = FileOpen($OutnameHF, 0)

While 1

$read = FileReadLine($afile)

If @error = -1 Then ExitLoop

For $x = 1 to $test[0]

If StringInStr($test, $read) = $read Then

MsgBox(0, 'Test', $test & $read)

EndIf

Next

WEnd

FileClose($afile)

I just want it to post in a message box both instances of the filename being searched for. I can get it to print a . in the message box, but not the name of the file.

Thank you for your help in advance.

Jeff

Link to comment
Share on other sites

I'm working on a script to read each line from a text file and use that line to search another text file for the instance from the first text file. I'm doing a directory listing of two folders and creating the text files. Here is my code that I'm working with.

$folder = "D:\iehotfix\rtmgdr"

$OutnameHF = "D:\iehotfix.txt"

$OutnameSys32 = "D:\system32.txt"

#include <file.au3>

Dim $test

_FileReadToArray($OutnameSys32, $test)

$afile = FileOpen($OutnameHF, 0)

While 1

$read = FileReadLine($afile)

  If @error = -1 Then ExitLoop

    For $x = 1 to $test[0]

      If StringInStr($test, $read) = $read Then

      MsgBox(0, 'Test', $test & $read)

      EndIf

    Next

WEnd

FileClose($afile)

I just want it to post in a message box both instances of the filename being searched for.  I can get it to print a . in the message box, but not the name of the file.

Thank you for your help in advance.

Jeff

<{POST_SNAPBACK}>

I may be wrong but your line:

If StringInStr($test, $read) = $read Then *****<---

should read

If StringInStr($test, $read) Then

do stuff

.....

The stringinstr command returns either 0=false or the position if found.

hth

HardCopy

Edited by HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...