Jump to content

If StringInStr($TexttobeRead1, "text") recheck every loop?


 Share

Recommended Posts

Hi,

I've setup a loop that will execute some piece of script whenever some piece of text is found in some text file.

The problem is that when I run the script while the text file has the text in it, it does run the piece of script, but when I then empty the text file it will not "recheck", but it still assumes that the text is in it for the next loop. How can I fix this?

$TexttobeRead = FileRead("C:\Documents and Settings\Tom\Bureaublad\Spel\example.log");text to be read

Func DeleteLog();Function to delete log files
FileDelete("C:\Documents and Settings\Tom\Bureaublad\Spel\example.log")
EndFunc

While 1;Start Loop
If StringInStr($TexttobeRead, "text") Then
MsgBox(64, "Tutorial", "The file has the specified text.")
DeleteLog()
EndIf

Wend;End Loop

EDIT:

I fixed it myself =)

Func DeleteLog();Function to delete log files
FileDelete("C:\Documents and Settings\Tom\Bureaublad\Spel\example.log")
EndFunc

While 1;Start Loop
$TexttobeRead = FileRead("C:\Documents and Settings\Tom\Bureaublad\Spel\example.log");text to be read
If StringInStr($TexttobeRead, "text") Then
MsgBox(64, "Tutorial", "The file has the specified text.")
DeleteLog()
EndIf

Wend;End Loop
Edited by tom13
Link to comment
Share on other sites

Hi,

I've setup a loop that will execute some piece of script whenever some piece of text is found in some text file.

The problem is that when I run the script while the text file has the text in it, it does run the piece of script, but when I then empty the text file it will not "recheck", but it still assumes that the text is in it for the next loop. How can I fix this?

(Snip)

Put the FileRead in the loop:

Func DeleteLog();Function to delete log files
    FileDelete("C:\Documents and Settings\Tom\Bureaublad\Spel\example.log")
EndFunc

While 1;Start Loop
    $TexttobeRead = FileRead("C:\Documents and Settings\Tom\Bureaublad\Spel\example.log");text to be read
    If StringInStr($TexttobeRead, "text") Then
        MsgBox(64, "Tutorial", "The file has the specified text.")
        DeleteLog()
    EndIf
Wend;End Loop

EDIT: I see you found your problem :shocked:

Edited by Paulie
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...