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;
}