Micro Focus QTP (UFT) Forums
exit parent functions as well - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: exit parent functions as well (/Thread-exit-parent-functions-as-well)



exit parent functions as well - Shridevi.Salagare - 07-29-2013

Is there any way we can exit the parent function as well.
E.g
Function F1
call F2
.....
.....
End Function

So if during execution of function F2 it fails and i want to exit function F2 as well as F1..Can we do that using code?


RE: exit parent functions as well - basanth27 - 07-30-2013

How about using "Exit Function" if the condition fails?


RE: exit parent functions as well - Shridevi.Salagare - 07-30-2013

Exit function would exit only current Function .I want to exit Its parent function as well.


RE: exit parent functions as well - Ankur - 07-31-2013

Assign some unique value just before you wish to Exit the first function. Check for that return value using a conditional statement and Exit if that matches. You can extend this logic to any number of nested function calls, just need to have a unique return key

Code:
Function Ex1()    
    Ex1 = 0
    Exit Function
End Function

Function Ex2()
    Ret = Ex1()
    If Ret = 0 Then
    msgbox Ret
    'Exit Function    
    End If
End Function

Call Ex2()

Hope that helps!