Description
This property is used for iteration through the collection of the ScriptRoutine
objects to which the given iterator provides access. Next
moves the iterator to the next ScriptRoutine
object in the collection. To determine whether the next object exists, use the ProjectRoutinesIterator.HasNext
method.
Declaration
ProjectRoutinesIteratorObj.Next
Read-Only Property | A ScriptRoutine object |
ProjectRoutinesIteratorObj | An expression, variable or parameter that specifies a reference to a ProjectRoutinesIterator object |
Applies To
The property is applied to the following object:
Property Value
A ScriptRoutine
object that provides information about a script routine.
Example
The following example demonstrates how to obtain information on the script routines that belong to the specified test project. The sample Visual Basic and C# applications obtain the script routines and display information on them.
Visual Basic
' Initializes variables
sProjectNameFileName = "C:\Work Folder\TestSuite\TestSuite.pjs"
sProjectName = "TestProject_VB"
' Creates the application object
Set TestCompleteApp = CreateObject("TestComplete.TestCompleteApplication.14")
' Obtains the integration object
Set IntegrationObject = TestCompleteApp.Integration
' Opens the project
IntegrationObject.OpenProjectSuiteEx sProjectNameFileName
' Needed to process errors
Err.Clear
On Error GoTo Err_Label
UserForm1.TextBox1.Text = ""
UserForm1.Label1.Caption = ""
' Obtains the RoutinesIterator object
Set RoutinesIterator = IntegrationObject.ProjectRoutinesIterator(sProjectName)
Params = ""
Info = ""
RoutinesIterator.Reset
' Obtains the script routine
Set Routine = RoutinesIterator.Next
' Posts information on the project and project suite
Info = "Project: " & Routine.ProjectName & vbCrLf & _
"Project File: " & Routine.ProjectFileName & vbCrLf & vbCrLf & _
"Project Suite: " & Routine.ProjectSuiteName & vbCrLf & _
"Project Suite File: " & Routine.ProjectSuiteFileName
UserForm1.Label1.Caption = Info
RoutinesIterator.Reset
Info = ""
' Iterates through the project’s routines
While RoutinesIterator.HasNext
Set Routine = RoutinesIterator.Next
If Routine.ParamCount > 0 Then
Params = "("
For i = 0 To Routine.ParamCount - 2
Params = Params & Routine.ParamType(i) & " : " & Routine.ParamName(i) & "; "
Next i
Params = Params & Routine.ParamType(Routine.ParamCount - 1) & " : " & _
Routine.ParamName(Routine.ParamCount - 1) & ")"
Else
Params = ""
End If
' Displays information on the routine
Info = Info & "Routine: " & Routine.Name & Params & vbCrLf & _
"Unit: " & Routine.UnitName & vbCrLf & _
"Script language: " & Routine.Language & vbCrLf & _
"Tree path: " & Routine.ProjectExplorerTreePath & vbCrLf & _
"Script File: " & Routine.ScriptFileName & vbCrLf
Info = Info & vbCrLf
Wend
UserForm1.TextBox1.Text = Info
Err_Label:
' Processes errors
If Err.Number <> 0 Then
MsgBox "An error has occurred while processing the script routines: " + Err.Description, vbCritical, "Error"
End If
' Quits TestComplete
TestCompleteApp.Quit
End Sub
C#
using System.Runtime.InteropServices;
using TestComplete;
…
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btn_Connect_Click(object sender, EventArgs e)
{
const string TCProgID = "TestComplete.TestCompleteApplication.14";
object TestCompleteObject = null;
// Obtains access to TestComplete
try
{
TestCompleteObject = Marshal.GetActiveObject(TCProgID);
}
catch
{
try
{
TestCompleteObject = Activator.CreateInstance(Type.GetTypeFromProgID(TCProgID));
}
catch
{
}
}
if (TestCompleteObject == null) return;
// Obtains ITestCompleteCOMManager
TestComplete.ITestCompleteCOMManager TestCompleteManager = (TestComplete.ITestCompleteCOMManager) TestCompleteObject;
// Obtains Integration object
TestComplete.ItcIntegration IntegrationObject = TestCompleteManager.Integration;
// Loads the project suite
IntegrationObject.OpenProjectSuiteEx("C:\\Work Folder\\TestSuite\\TestSuite.pjs");
try
{
// Obtains script routines of the TestProject_VB project and displays their names
TestComplete.ItcEnumScriptRoutine RoutinesIterator = IntegrationObject.get_ProjectRoutinesIterator("TestProject_VB");
// Creates a list view that will display information on the project script routines
ListView NewRoutinesList = new ListView();
NewRoutinesList.View = View.Details;
NewRoutinesList.FullRowSelect = true;
NewRoutinesList.Sorting = SortOrder.Ascending;
NewRoutinesList.Size = new Size(400, 200);
NewRoutinesList.Top = 41;
NewRoutinesList.Left = 12;
// Create columns for the routines information
NewRoutinesList.Columns.Add("Routine");
NewRoutinesList.Columns.Add("Unit");
NewRoutinesList.Columns.Add("Language");
NewRoutinesList.Columns.Add("Project");
NewRoutinesList.Columns.Add("Project File");
NewRoutinesList.ShowItemToolTips = true;
// Creates a text box that will display information on the current project suite
RichTextBox InfoTextBox = new RichTextBox();
InfoTextBox.Size = new Size(400, 35);
InfoTextBox.Top = 300;
InfoTextBox.Left = 12;
InfoTextBox.BorderStyle = BorderStyle.None;
InfoTextBox.Enabled = false;
// Obtains the project’s script routines
TestComplete.ItcScriptRoutine Routine = RoutinesIterator.Next;
InfoTextBox.Text = Routine.ProjectSuiteName + "\r\n" + Routine.ProjectSuiteFileName;
// Sets the iterator to the initial position
RoutinesIterator.Reset();
// Iterates through the project routines and adds information on them to the list view
while (RoutinesIterator.HasNext())
{
// Obtains the script routine
Routine = RoutinesIterator.Next;
// Adds project routine to the list
string name;
name = Routine.Name;
if (Routine.ParamCount != 0)
{
name = name + "(";
for (var i = 0; i < Routine.ParamCount - 1; i++)
{
name = name + Routine.get_ParamType(i) + " : " + Routine.get_ParamName(i) + "; ";
}
name = name + Routine.get_ParamType(Routine.ParamCount - 1) + " : " + Routine.get_ParamName(Routine.ParamCount - 1) + ")";
}
ListViewItem newitem = new ListViewItem(name, 0);
newitem.SubItems.Add(Routine.UnitName);
newitem.SubItems.Add(Routine.Language);
newitem.SubItems.Add(Routine.ProjectName);
newitem.SubItems.Add(Routine.ProjectFileName);
newitem.ToolTipText = Routine.ScriptFileName;
NewRoutinesList.Items.AddRange(new ListViewItem[] { newitem });
}
// Adds the list view to the form
this.Controls.Add(NewRoutinesList);
this.Controls.Add(InfoTextBox);
…
}
catch (System.Runtime.InteropServices.COMException ex)
{
System.Windows.Forms.MessageBox.Show("An exception occurred: " + ex.Message);
}
finally
{
TestCompleteManager.Quit();
// Releases COM objects
Marshal.ReleaseComObject(IntegrationObject);
Marshal.ReleaseComObject(TestCompleteManager);
Marshal.ReleaseComObject(TestCompleteObject);
}
}
}
See Also
HasNext Method
Reset Method
ScriptRoutine Object
Working With TestComplete via COM - Overview