Implementing a generic Iterator

This recipe will describe how to implement a mechanism that is able to execute any operation for objects of any class repeatedly, until a condition is met or until the whole queue of objects is processed. The condition can be any expression that results in a Boolean value.

Getting ready

Create a new function library (for instance, cls.Iterator.vbs), and associate it with your test. In this recipe, we shall use the code from the previous recipe, Implementing function pointers.

How to do it...

Proceed with the following steps:

  1. In the function library, write the following code:
    Class Iterator Public Default Function Run(ByRef oCollection, _ ByRef ptrFunction, _ ByVal dicArgs, _ ByVal sExitCondition) Dim count, items, ix, ...

Get Advanced UFT 12 for Test Engineers Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.