LoadRunner Practitioners Forum

What is differnce between return 0 ,return -1 and lr_exit

Frequent Contributor.

What is differnce between return 0 ,return -1 and lr_exit

Dear All,

Can you please let me know what is the differnce between return 0 ,return -1 & lr_exit in LoadRunner .



KMR Hexa

Super Contributor.

Re: What is differnce between return 0 ,return -1 and lr_exit





Causes the current function to terminate. It can return a value to the calling function. A return statement can appear in a function whose return type is void. If the value returned has a type different from that of the function's return type, then the value is converted. Using the return statement without an expression creates an undefined result. Reaching the brace } at the end of the function is the same as returning without an expression.


Difference Between return 0 , return -1 & lr_exit


for example If you trying to assign / allocate something like memory through script using some function, If allocation is unsuccessful, the function returns with a -1 value. If successful, the function continues and returns 0 at completion.


lr_exit function will be used in a situations where you want to exit from the Script, Action or iteration based on some conditions.


For further information, please refer HP Loadrunner Online Reference.




Super Contributor.

Re: What is difference between return 0 ,return -1 and lr_exit

I often use 

return -1;

when I am debugging a script. The script will stop immediately (and not run vuser_end). This is a quicker way to run to a breakpoint and then stop the script.

You can also use

return <action section>

and run a specific action section. This can get a bit messy as action section flow is set by run time settings, so you may get an "extra" hit on an action section. You can use this method to run an action section that is not in the run time settings (for conditional code). Suggest you have a play first!