Jump to content
Sign in to follow this  
Cambo

Do...Until OR 30 secs [How To?]

Recommended Posts

Cambo

I have a Do...Until loop that constantly reads a file for a certain line. Sometimes this doesn't show up, depending on certain circumstances. It looks like this:

Do
Sleep(100)
$Check = FileRead("log")
Until StringInStr($Check, "RandomString")

but sometimes RandomString, doesn't show up. I want it to run this loop until that shows up OR until a set time (like 30 secs) has gone by. I know after 30 secs it is safe to go on, even if RandomString hasn't shown up. I'm not quite sure how to do this. I could put a counter in it, and have it up date the variable and when the variable reaches 300 (30 secs with a Sleep(100)) have an OR $var = 300 at in the Until line, but that seems like a lot of work for something that simple. Any other ideas?

Any help would be greatly appreciated!!

Edited by Cambo

Share this post


Link to post
Share on other sites
Generator

$Timer=TimerInit()
Do
Sleep(100)
$Check = FileRead("log")
Until StringInStr($Check, "RandomString") Or TimerDiff($Timer)>(1000*30)
Edited by Generator

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.