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;
Scott Moore

About Scott Moore (153 articles)

With over 18 years of IT experience with various platforms and technologies, Scott has tested some of the largest applications and infrastructures in the world. He has mentored and developed testing services for Big Five services firms, top insurance companies, and major financial institutions in the US. In 2004, Scott founded Loadtester Incorporated, focusing on performance testing and building centers of excellence around application performance. He is a Certified Instructor and Certified Product Consultant in HP’s LoadRunner and Performance Center products. In October 2010, Scott became President and CEO of Northway Solutions Group, with Loadtester remaining a subsidiary of the company. He currently holds HP certifications for ASE, ASC, and CI.

  • 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”);