Forum Discussion

ZXQA's avatar
Occasional Contributor
4 years ago

Identify current form for script use


   I am trying to write a reusable script with a data loop in TestComplete 12, VB Script.

Is there a way for me to identify the current active form? I have searched extensively and found nothing.


My script interacts with a data grid and enters a file determined number of items and is quite simple but I would like to use this identification feature in other scripts as well. The grid is on the same location of every form but the form name changes example below: 

1.  Sys.Process("Signon").WinFormsObject("frmPSSales").WinFormsObject("RightFillPan").WinFormsObject("clientPanel").WinFormsObject("SpDataGrid1")

2. Sys.Process("Signon").WinFormsObject("frmPSOrders").WinFormsObject("RightFillPan").WinFormsObject("clientPanel").WinFormsObject("SpDataGrid1")


I would like to capture the current "Sys.Process("Signon").WinFormsObject("********")." of the current form so it does not have to passed in to the function.


An example of what im doing is below:


frm = ""
frm = "This would be the retrieved form fullname or mapped name"
Call Project.Variables.itemNum.Reset
While Not Project.Variables.itemNum.IsEOF
'Enters the text Project.Variables.itemNum("ItemNumber") in the 'txtBase' text editor.
Call frm.UcGetItemA1.panBase.txtBase.SetText(Project.Variables.itemNum.Value("ItemNumber"))
'Enters '[Enter]' in the 'txtBase' object.
Call frm.UcGetItemA1.panBase.txtBase.Keys("[Enter]")
'Enters '[Enter]' in the 'SPTextBox' object.
Call frm.SPTextBox.Keys("[Enter]")
Call Project.Variables.itemNum.Next
End Sub


Any help is greatly appreciated.

5 Replies