Fire an event a percentage of the time
Question ID: 105070
1
0

How do I handle a web page in my script that can only happen a percentage of the time. Like I only request an update on a specific web page occasionally.

Marked as spam
Posted by (Questions: 23, Answers: 4)
Asked on July 19, 2013 1:56 pm
39 views
Answers (1)
1
Private answer

Description:

This is a simple script that can be used to handle an event that happens
on only a percentage of iterations. Sometimes a business process contains
a call that only happen occasionally. Use this code to simulate these
events by placing the server call within the event handler code block

=========================Init Section========================================

int Iteration = 0;
int EventCounter = 0; //This hold the number of events that occur

vuser_init()

{

srand ( time(NULL) ); //Seed the randomizer

return 0;
}

Actions()

{

int RAND_MAX = 100; //Maximum random value returned
int ThisVal = 0; //The current event value
int Frequency = 4; //Frequency controlls how often an event occurs.

/*** Event handler code block ***/
ThisVal = rand()%RAND_MAX; //Get a random number between 0 and RAND_MAX
if(ThisVal % Frequency == 0) //if the current value mod Frequency = 0
//generate an event
{
EventCounter++; //Count the number of events
lr_message(''Random Event''); /* Message here, but put your code here */
return 0;
}

Marked as spam
Posted by (Questions: 17, Answers: 266)
Answered on July 19, 2013 2:28 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top