Random Wait Time Question

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
csxtitan
Newbie
Posts: 3
Joined: Wed Aug 26, 2009 11:00 pm

Random Wait Time Question

Post by csxtitan » Wed Aug 26, 2009 11:02 pm

Is there a way to have a macro wait between 30 and 130 seconds before repeating itself?

If so, how would this be set up?

User avatar
JRL
Automation Wizard
Posts: 3518
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Aug 27, 2009 12:42 am

Macro Scheduler Help wrote:Random>Range,Result
Returns a random number within the specified range where 0 works, a random number between 0 and a programmer supplied upper range is generated each time Random> is called. Since you are asking for the lower part of the random range to be greater than 0, you have to manipulate your numbers a little. The upper range number will actually be 1 less than the number supplied, so you will specify 131 as your random number maximum. Then you subtract the smaller number from the larger number. In your case 131-30=101. 101 becomes the "range" for the Random> function. After the Random> function generates a number and assigns it to a variable you then add the number that is the lower portion of the range, in your case 30, to the result. The following two lines will give you a variable named "result" with a value that is a random number between 30 and 130.

Code: Select all

Random>101,result
Add>result,30
Put his code in your script with a wait call using the variable "result" as its parameter. You will then wait a random number of seconds between 30 and 130.

Code: Select all

Wait>%result%
Total code will look something like this:

Code: Select all

Label>Start

//Your current code

Random>101,result
Add>result,30
Wait>%result%
Goto>Start

Hope this helps.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts