There are Lr_save_int () and lr_save_string () functions in LoadRunner, but there is no lr_save_float function to save floating-point numbers to variables. "Lr_save_float () function for LoadRunner" This article describes how to write a function like this:
http://ptfrontline.wordpress.com/2010/01/27/lr_save_float-function-for-loadrunner/
void Lr_save_float (const float value, const char *param, const int decimals)
// ----------------------------------------------------------------------------
Saves a float into a LR variable, much as Lr_save_int () Saves an integer
//
Parameters:
Value Float value to store
param loadrunner Variable Name
Decimals number of decimals in the result string
//
Returns:
N/A
//
Example:
Lr_save_float (123.456, "MyVar", 2); MyVar = 123.46 (includes rounding)
//
// ----------------------------------------------------------------------------
{
Char buf[64]; If more>63 digits, your problem
Char formatbuf[16]; Chars should be adequate
sprintf (Formatbuf, "%%.%DF", decimals); Build the "%?. F "format string
sprintf (buf, formatbuf, value); sprintf the value
Lr_save_string (buf, param); Store in variable
}
Examples of use are as follows:
#include "Lr_save_float.h"
Vuser_init ()
{
Lr_save_float (123.456, "MyVar", 2);
Lr_output_message (Lr_eval_string ("{MyVar}"));
return 0;
}
Write a lr_save_float function for LoadRunner