Vugen: Using LAST Value For web_reg_save_param_ex

Whenever the ORD=ALL attribute is used with the web_reg_save_param_ex function, VuGen creates an array containing the number of instances that are actually captured. It also stores the total count for the number of instances automatically. This count can be referenced by getting the value of “_count”. For example, if the parameter name is ParamName, a separate parameter ParamName_count will be available with number of times the value was captured. This can also serve as index for last values captured. Use the sample code below to reference and use the last value captured by LoadRunner. You can get creative and use a random value instead or walk through the array to get other values too.


 int i;
 char last[30];
//Capture all occurrences of strings between <td> and </td>
//Get the total count of the parameter and
//save the information to a string
 sprintf (last, "{MyParam_%s}", lr_eval_string("{MyParam_count}"));
//extract the value of the last item and
// save it to a parameter called pLastValue
 lr_save_string( lr_eval_string(last) ,"pLastValue");
//send a message to the log showing the value of pLastValue
 lr_message("last value is %s", lr_eval_string("{pLastValue}"));
return 0;

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

  • Tony Gartrell

    I can write that code in less lines. You don’t need the sprintf. You can just do two lr_eval_strings.

    lr_save_string(lr_eval_string(lr_eval_string(“{MyParm_{MyParm_count}}”)), “pLastValue”);