INTERFACE/END INTERFACE block (IDBind)  

Purpose

Declare a dispatch interface and its member Methods/Properties for the purposes of IDBinding to a Dispatch COM interface.

Syntax

INTERFACE IDBIND interfacename

  MEMBER {CALL | GET | SET | LET} membername <dispid> ( [[OPTIONAL

      [IN | OUT | INOUT]] paramname <dispid> [AS type] [,...]] )

      [AS {vartype | interface}]

  [...]

END INTERFACE

Remarks

In order to provide IDBinding services, PowerBASIC must be able to pre-construct the references to the DISPATCH COM interface members at compile-time.  Without an interface definition block, only late-binding at run-time would be possible.  Late-binding is less efficient than IDBinding.

You may list every Method/Property in the interface, or just the ones that are referenced in the code.  They can appear in any sequence.  Member names may contain (normally) reserved keywords such as INPUT or KILL, etc

The most important aspect of an interface block is that it clearly associates a dispid with the each Method/Property name.  Named parameters in the paramname list also require an appropriate dispid value, as does any Property which returns an object to be used in a nested object reference.  All dispid values must be enclosed in angle brackets (< and >), and may be expressed as hexadecimal or decimal numeric literals.

You can look up the dispid values of COM servers using an Object Browser, or by reading your object documentation.  You can even insert additional information about the types and return value for your own reference, even though the compiler does not use them.

Previous versions of PowerBASIC compilers used an older style syntax of "INTERFACE DISPATCH interfacename" for this structure. It was updated to better reflect the nature of the description. While the older syntax will be recognized in this version, we suggest you update the word DISPATCH to IDBIND soon.  

Restrictions

If the compiler cannot resolve the interface name definition specified in a DIM or LET statement, a compile-time error is generated accordingly.

interfacename must not be a PowerBASIC keyword.  If a keyword conflict arises, the addition of an arbitrary prefix is acceptable.  For example, INTERFACE IDBIND Shell() could be changed to INTERFACE IDBIND MyShell() and PowerBASIC will still resolve the interface correctly.

Method/Property membername items may freely use PowerBASIC keywords without concern for conflicts with normal code syntax.  For example, MEMBER CALL Open() is a valid syntax for an interface method.

See also

DIM, ID Binding, INTERFACE (Direct), ISINTERFACE, LET (with Objects), Late Binding, LET (with Variants), OBJACTIVE, OBJECT, OBJPTR, OBJRESULT, PROGID$, What is an object, anyway?, What is DISPATCH?

Example

INTERFACE IDBIND IAPPUser

  MEMBER CALL DELETE<&H1>()

  MEMBER GET Name<&H2>() AS STRING

  MEMBER LET Name<&H2>() 'Param Type As String

  MEMBER LET Password<&H3>() 'Param Type As String

  MEMBER GET ReadOnly<&H4>() AS LONG

  MEMBER LET ReadOnly<&H4>()   'Param Type As Long

  MEMBER GET ProjectRights<&H5>(OPTIONAL IN Project AS STRING<&H0>) AS LONG

  MEMBER LET ProjectRights<&H5>(OPTIONAL IN Project AS STRING<&H0>)

  MEMBER CALL RemoveProjectRights<&H6>(IN Project AS STRING<&H0>)

END INTERFACE

 

INTERFACE IDBIND IAPPItems

  MEMBER GET Count<&H1>() AS LONG

  MEMBER GET Item<&H0>(IN sItem AS VARIANT<&H0>) AS IAPPItem

END INTERFACE

 

DIM oApp AS IAPPUser

LET oApp = NEW IAPPUser IN "com.server.0"