lr_save_int Function in Loadrunner with Examples

First of all, we should understand what is this function lr_save_int all about. Main purpose of this function is to save an integer to a parameter. Parameter in LoadRunner can be considered as a variable that can store some value and this function is used to assign an integer value to the variable or what is called parameter in LoadRunner. The syntax of this function is as given below.

int lr_save_int ( int value, const char *param_name);

Example: lr_save_int     Parameter Functions

There are two arguments in the function which are given below.

value     The integer value to assign to the parameter.

param_name    The name of the parameter.

Let us understand it in little more detail. First of all, this function will convert an integer to a string and only after that, it saves integer value to the parameter.

One thing to be noted is that this function returns LR_PASS when it is success otherwise, it returns a negative value.

Let us understand it with the help of an example.

// declaring a variable i of type integer

int i;

// assigning a value to the integer variable i. Now the value of i is 433.

i = 433;

// assigning value contained in the variable i (433) to the parameter prmCounter

lr_save_int(i, “prmCounter”);

// evaluating value which is contained in the parameter and printing that in the output log window of LoadRunner.

lr_output_message(“String value of prmCounter: %s”, lr_eval_string(“{prmCounter}”));

Let us see how the code looks like in the LoadRunner window.

lr_save_int

We have seen in the above example, how we have assigned one variable with some value and how we are assigning that value to a parameter in LoadRunner and how we are printing the value of that parameter in the output log window of LoadRunner. Let us see the output of this code example shown above to see whether it is performing as per expectation or not. In the output log window, we should see the following message appearing in the output log window of the LoadRunner, where we are evaluating the value of the parameter prmCounter to which integer value is assigned and then printing the value of that parameter prmCounter in the output log window loadrunner.

String value of prmCounter: 433

Output log appearing in the the log window of LoadRunner is as given below.

Ending action vuser_init.

Running Vuser…

Starting iteration 1.

Maximum number of concurrent connections per server: 6        [MsgId: MMSG-26989]

Starting action Action.

Action.c(10): String value of prmCounter: 433

Ending action Action.

Ending iteration 1.

We can also see the output log window, as appearing in output log window of LoadRunner, in the form of screenshot given below. We can clearly see that it is working as per expectation. Also, we can see that it is printing output value as “String value of prmCounter: 433 “.

lr_save_int function in Loadrunner With Examples

Overall, we can say that it is a very useful function that is used in LoadRunner for saving integer value to parameter and before saving the integer value to the parameter, it converter integer value to the string format.

You should also read all the loadrunner functions with examples.