Book Image

Advanced UFT 12 for Test Engineers Cookbook

Book Image

Advanced UFT 12 for Test Engineers Cookbook

Overview of this book

Table of Contents (18 chapters)
Advanced UFT 12 for Test Engineers Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing function pointers


What is a function pointer? A function pointer is a variable that stores the memory address of a block of code that is programmed to fulfill a specific function. Function pointers are useful to avoid complex switch case structures. Instead, they support direct access in runtime to previously loaded functions or class methods. This enables the construction of callback functions. A callback is, in essence, an executable code that is passed as an argument to a function. This enables more generic coding, by having lower-level modules calling higher-level functions or subroutines.

This recipe will describe how to implement function pointers in VBScript, a scripting language that does not natively support the usage of pointers.

Getting ready

Create a new function library (for instance, cls.FunctionPointers.vbs) and associate it with your test.

How to do it...

  1. Write the following code in the function library:

    Class WebEditSet
        Public Default Function Run(ByRef obj, ByVal...