More Old School Vugen Code For Randomization

Here is some old code I had laying around which simply illustrates how to randomize a VuGen parameter by using srand and randomizing a value used within the array. This assumes you are grabbing multiple values in the array using the web_reg_save_param() function with the ORD=ALL argument.

// Randomize based on total numbers of Beneficiaries and selecting one
 
srand( time(NULL) );
rnum1 = (rand () % atoi(lr_eval_string("{pBeneficiary_count}")) +1);
 
// Merge Parameter to include the random number just selected
 
 sprintf( buffer1,"{pBeneficiary_%d}",rnum1 );
 
// save converted string into a parameter for Beneficiary
 
 lr_save_string( lr_eval_string(buffer1),"pRndAccounts" );

Let us know your thoughts by leaving a comment below.

What's Next?

Did you enjoy this article? Help spread the word by sharing:

Join the Northway Navigator Club today and get access to restricted content including our best tips and tricks. Membership is free! You will also receive free email updates by registering.

Engage in the conversation and leave a comment:

Scott Moore

About Scott Moore (153 articles)

With over 20 years of IT experience with various platforms and technologies, Scott has tested some of the largest applications and infrastructures in the world. He is a Certified Instructor and Certified Product Consultant in HP’s LoadRunner and Performance Center products. He currently holds HP certifications for ASE, ASC, and CI. A thought leader in the APM space, he speaks regularly at IT conferences and events