Just a quick post of a potentially useful function for LoadRunner
2010-05-17 20:58
459 查看
Just a quick post of a potentially useful function for LoadRunner.
LoadRunner
has lr_save_int() and lr_save_string() but the float saving function is
missing so I just quickly whipped up the following code. It’s by no
means perfect when it comes to checking for errors, but it will work
>90% of the times (as long as the scripter knows what he/she is
doing).. Enjoy.
Code:
LoadRunner
has lr_save_int() and lr_save_string() but the float saving function is
missing so I just quickly whipped up the following code. It’s by no
means perfect when it comes to checking for errors, but it will work
>90% of the times (as long as the scripter knows what he/she is
doing).. Enjoy.
Code:
void lr_save_float(const float value, const char *param, const int decimals) // ---------------------------------------------------------------------------- // Saves a float into a lr variable, much like 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 <img src="http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley"> char formatbuf[16]; // 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 }
相关文章推荐
- What can I learn right now in just 10 minutes that could be useful for the rest of my life?
- What can I learn right now in just 10 minutes that could be useful for the rest of my life?
- JS:Trim() in javascript, how to define a function of checkinput for a WebControl(ascx)
- Undefined function 'adb' for input arguments of type 'double'.
- Program names ZX... are reserved for includes of exit function groups
- matlab12A版本中MATLAB在运行的时候出现??? Undefined function or method 'uiopen' for input arguments of type 'cha
- Type of the default value for 'data' prop must be a function的解决方法
- linux_ 25 Useful Basic Commands of APT-GET and APT-CACHE for Package Management
- Top 20 Online Tools Useful For Any Type of Web Developer
- Undefined function 'conv2' for input arguments of type 'double' and attributes 'full 3d complex'.
- Undefined function or method ' ' for input arguments of type 'double' ---错误解决办法
- [解决]Hive执行语句:Unable to create temp file for insert values Expression of type TOK_FUNCTION not suppor
- 解决Undefined function or method 'vgg_kmiter' for input arguments of type 'double'.
- matlab 出现Undefined function 'functionname' for input arguments of type 'logical'问题的解决办法
- 25 Useful Basic Commands of APT-GET and APT-CACHE for Package Management
- 每日英语:Finding The Just-Right Level Of Self-Esteem For A Child
- 错误(Undefined function 'produce' for input arguments of type 'double'.)
- using tail recursion to reverse words of line ( just for fun)
- derivative of cost function for Logistic Regression 逻辑回归代价函数偏导证明
- matlab错误:Function 'conv2' is not defined for values of class 'double' and attributes