Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Finding a string in a text file

$
0
0

Hi, I am pretty new to AutoIT and also new to scripting/programming - so please take it easy :)

 

I am trying to determine if a string is present in a text file. The code is below.. it does not work and I am even more confused now then when I started.. 

 

can anyone please help 

 

Many thanks in advance, Steve 

 

#include <File.au3>
 
$filetosearch = FileOpen("new.txt", 0)
 
While 1
$line = FileReadLine($filetosearch)
If @error = -1 Then ExitLoop
If StringInStr("$line", "bad") Then
MsgBox(0, "Found", $line)
Else
MsgBox(0, "not found", $line)
FileClose($filetosearch)
EndIf
WEnd
FileClose($filetosearch)

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>