Purpose |
Declare a dispatch interface and its member Methods/Properties for the purposes of early-binding to a COM interface. |
Syntax |
INTERFACE DISPATCH 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 early-binding services, PowerBASIC must be able to pre-construct the references to the 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 early-binding. 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. |
Restrictions |
If the compiler cannot resolve the interface name definition specified in a DIM, LET, or SET 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 DISPATCH Shell() could be changed to INTERFACE DISPATCH 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, Members, Methods and Properties, OBJACTIVE, OBJECT, OBJPTR, OBJRESULT, Parameters, PROGID$, Return Data, SET |
Example |
INTERFACE DISPATCH 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 DISPATCH 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" |