0

Please see below function fnWaitCheckFinalStatus if Else part is executed in below code then value return by Function fnWaitCheckFinalStatus is coming blank because function this is called recursively fnWaitCheckFinalStatus.

Is there way to get return value of fnWaitCheckFinalStatus After exit function function should exit all its state.

How can I make it possible , any pointers on this.

Function fnWaitCheckFinalStatus(objStatusBar)

    Dim blnRetValue : blnRetValue = True
    Dim i : i=0 

    If objStatusBar.Exist Then
        strValue=ObjStatusBar.GetROProperty("text") 

        Do
            wait 10
            strValue=ObjStatusBar.GetROProperty("text")
        Loop While strValue = "Task Started"

    End If

    strValue1=ObjStatusBar.GetROProperty("text")
    If strValue1="Task executed successfully" Then
        blnRetValue1=True
        fnWaitCheckFinalStatus = blnRetValue1
        Exit Function
    ElseIf strValue1="Task execution failed" Then
        blnRetValue1=False
        fnWaitCheckFinalStatus = blnRetValue1
        Exit Function
    Else
        Call fnWaitCheckFinalStatus(objStatusBar)
    End If  

End Function
0

1 Answer 1

1

Consider "pass-through"ing the function result if you return from the recursion, like in this code (note the line with the !!! comment):

Function fnWaitCheckFinalStatus(objStatusBar)

    Dim i : i=0 

    If objStatusBar.Exist Then
        strValue=ObjStatusBar.GetROProperty("text") 

        Do
            wait 10
            strValue=ObjStatusBar.GetROProperty("text")
        Loop While strValue = "Task Started"

    End If

    strValue1=ObjStatusBar.GetROProperty("text")
    If strValue1="Task executed successfully" Then
        fnWaitCheckFinalStatus = true
    ElseIf strValue1="Task execution failed" Then
        fnWaitCheckFinalStatus = false
    Else
        fnWaitCheckFinalStatus=fnWaitCheckFinalStatus(objStatusBar) ' !!!
    End If  

End Function

Also, I eliminated the result buffer variable. You don´t need it, so you can scratch it.

Also, I'd avoid exit function in this case to keep the code simpler (one entry point, one exit point), so I eliminated that, too.

Generally speaking, there is no obvious reason for using recursion here since you pass exactly the same argument as you receive, so the recursive call will do exactly the same as its caller scope. Use a loop instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.