Problem Description: How to convert a parameter to an integer
Solution: Use the atoi function
To convert a parameter to integer:
1. Covert the parameter to a string using lr_eval_string.
Example:
lr_eval_string("{Parameter_name}")
2. Convert the string to a number using atoi.
Example:
x=atoi(lr_eval_string("{Parameter_name}") );
Example:
Action()
{
int x;
char temp[20];
/* Tell LoadRunner what to look for in next return from server*/
web_reg_save_param("example", "LB=copy; ", "RB=, Mercury Corporation ",LAST);
/* Make request of server that returns the data we are looking for */
web_url("MERCURY", "URL=http://www.mercury.com", LAST);
/* Check to see what was captured */
lr_output_message("%s", lr_eval_string("{example}") );
/*Convert the parameter to a string, and convert the string to a number*/
x=atoi(lr_eval_string("{example}") );
/* Output the number*/
lr_output_message("%d", x);
return 0;
}
|