What is differnce between return 0 ,return -1 and lr_exit (342 Views)
Occasional Contributor
Posts: 6
Registered: ‎05-15-2013
Message 1 of 3 (342 Views)

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

Please use plain text.
Valued Contributor
Posts: 99
Registered: ‎07-24-2012
Message 2 of 3 (338 Views)

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.




Please use plain text.
Frequent Advisor
Posts: 74
Registered: ‎08-19-2010
Message 3 of 3 (281 Views)

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! 

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation