Creating a late-bound object variable

Declaring a late-bound object variable is pure simplicity - we only need to declare it as a DISPATCH type and no INTERFACE blocks are required to be defined.  For example:

FUNCTION PBMAIN

  DIM oWord AS DISPATCH

  LET oWord = NEW DISPATCH IN "Word.Application"

  ...

END FUNCTION

In both cases above, and assuming the Object could be initialized, the object variable oWord contains the Dispatch Interface reference to the Object.  The LET statement may not set the ERR system variable if any run-time problems are encountered during the initialization of the Object, so you should use the ISOBJECT function to check state status of the object variable oWord.

 

See Also

COM Programming Introduction

The PowerBASIC COM Browser

Creating an early-bound object variable

What is a Dispatch Interface?

How does the LET statement work?

Early-binding and Late-binding