Home  |  My Software  |  Links
You are here: Home > Software > VBScript RegExp Wrapper for Delphi 7

Delphi 7 Wrapper for the Microsoft VBScript 5.5 RegExp Classes

This is a Delphi 7 unit that provides type-safe access to the Microsoft VBScript 5.5 RegExp Automation Classes.

The Microsoft VBScript 5.5 RegExp Automation Classes can be imported and used directly in Delphi programs by using Delphi Import Type Library command (the type library to look for is called "Microsoft VBScript Regular Expressions 5.5").

However due to the fact that the RexExp Automation Classes have been designed for use in weakly typed scripting languages, the resulting type library is far from ideal from the perspective of a strongly typed language like Delphi:

  1. The VBScript RegExp Classes refer to each other using raw Dispatch interfaces. This forces Delphi programs to either manipulate them using Variants (and risk calling the wrong methods) or to continually have to cast them to the real interface. In both cases errors will only be caught at runtime when in general it is too late...
  2. All errors are returned via numerical HRESULTs. As far as I have been able to see no one of the coclasses supports COM rich errors via ISupportsErrorInfo, so there is no way to get a textual description of the returned error from the classes themselves. Luckily the numerical HRESULT values are documented in MSDN.

For all these reasons I have found more convenient to encapsulate access to the RegExp classes using proxy interfaces. This way it is in fact possible to both enforce type safe access and translate COM errors to Delphi exceptions.

Downloads

Delphi Wrapper for the Microsoft VBScript 5.5 RegExp Library

Delphi 7 Unit (.pas)

format:WinZip size:5 KB last modified:03-Nov-2003