Jump to content
Sign in to follow this  
tom13

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

Recommended Posts

tom13

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

Share this post


Link to post
Share on other sites
Paulie

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.