Finally, parameters can be passed in two ways: Positional and Named mode. Positional parameters work just like conventional parameter passing - the actual order of the parameters being passed must agree with the declared order in the INTERFACE member block.
However, using Named parameters offers a whole new way of specifying parameters. With Named parameters, code takes on an almost "self-documenting" parameter format, and since parameters are explicitly named, they can be specified in any order.
This is best explained by example. The following two OBJECT CALL statements are equivalent; however, the first OBJECT CALL statement uses positional passing, whereas the second uses named parameter passing.
INTERFACE DISPATCH IVSSDatabase
MEMBER CALL Open<&H1>(OPTIONAL IN SrcSafeIni AS STRING<&H0>, OPTIONAL IN Username AS STRING<&H1>, OPTIONAL IN Password AS STRING<&H2>)
END INTERFACE
...
' Positional parameter passing
OBJECT CALL oVss.Open(vIni, vUser, vPassword)
' Named parameter passing
OBJECT CALL oVss.Open(SrcSafeIni=vIni, Username=vUSER, Password=vPassword)
As mentioned above, Named parameters can be specified in any order. For example, the following statement is also equivalent to the two previous statements:
OBJECT CALL oVss.Open(Username=vUSER, Password=vPassword, SrcSafeIni=vIni)
It is also possible to mix Positional and Named parameters in a single OBJECT statement, but positional parameters must precede all Named parameters. It must be noted that not all COM Objects support Named parameters, but most do accept Named parameters.
Care should be exercised when reallocating or clearing Variant variables that have been used
as parameters passed to a COM Object, since asynchronous execution in
COM Object could require the Variant data be present for some duration
or operation.
This behavior largely depends on the design of the COM Object; however,
unexpected General Protection Faults (GPFs) in the COM Object can occasionally
be traced to inopportune reallocating or clearing a Variant parameter
in the client code.
See Also