Micro Focus QTP (UFT) Forums
how to continue after running a function - 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: how to continue after running a function (/Thread-how-to-continue-after-running-a-function)



how to continue after running a function - yuetling926 - 10-08-2009

Hi everybody,

As I am just a Beginner in QTP. I got a question here.
I have found a function and the function run properly.
However, I don't know how to set the Qtp to continues with the scripts when "intRows = 1". If "intRows" doesn't equal to 1, then an error should pop-put.
Can anyone help ?

Here is the function I found.
Function GetSiebListRows( byRef oSiebApplet, pValUINameSiebList )
'—————————————————————————————————————————
Code:
'SiebList is a list object in a Siebel test automation environment

  Dim vCounter
  If InStr(1, pValUINameSiebList, "uiname") <> 0 Then
    pValUINameSiebList = Trim(Split(pValUINameSiebList, ":=")(1))
  End If

  'From QTP Ref:
  '_ The RecordCounter indicates the visible text of the record counter
  '_ string (for example: 1 - 7 or 7+)
  vCounter = oSiebApplet.RecordCounter

  Do
    If InStr(1, vCounter, "+") <> 0 Then
      oSiebApplet.SiebList("uiname:=" & pValUINameSiebList).NextRowSet
      vCounter = oSiebApplet.RecordCounter
    Else
      vCounter = oSiebApplet.RecordCounter
      Exit Do
    End If
  Loop

  If InStr(1, vCounter, "of") <> 0 Then
    vCounter = CInt(Trim(Split(CStr(vCounter), "of")(1)))
  End If

  GetSiebListRows = vCounter
End Function


Dim oSiebApplet, intRows
Set oSiebApplet = SiebApplication("Siebel Energy (CMS DR)").SiebScreen("Agreement").SiebView("Agreement Charges").SiebApplet("Invoices")
intRows = GetSiebListRows( oSiebApplet, "uiname:=List" )



RE: how to continue after running a function - Saket - 10-08-2009

In which part of the code you are having difficulty, as per your explanation I understood that your function GetSiebListRows is working fine and you are getting the output in intRows. No you want to check some condition and proceed further. right? Correct me I am wrong.

you can simply use an IF..Then..Else
Code:
IF intRows <> 1 then[hr]
you can simply use an IF..Then..Else
[code]
IF intRows <> 1 then
msgbox "Error"
else
Your Further statements..
end if



RE: how to continue after running a function - yuetling926 - 10-09-2009

this is helpful ,thanks
Jody