[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: "indexed" COM properties in MysterX?



Reini Urban wrote:
> I believe you are wrong here. You just want a macro to chain the
> com calls.
>
> (display (com-get-chained flds "Item" "Name"))
> => (display (com-get-property (com-get-property flds "Item") "Name"))

Paul's already answered this correctly, but I'll expand on that a bit.  The
value being accessed in my original example would typically be accessed in,
say, VBScript or JScript using syntax such as the following:

	flds("Name")

However, this relies on the default property of the Fields interface,
"Item", so the real call is:

	flds.Item("Name")

As I pointed out in my original message, "Item" is declared as a property
which takes one parameter in the COM interface definition, which is as
follows:

	[id(00000000), propget]
	HRESULT Item( [in] VARIANT Index, [out, retval] Field** ppvObject );

Calling "Item" without a parameter fails, at the COM level, because Item is
really a function (declared as a property accessor) which *requires* exactly
one input argument.  This argument is the index (string or ordinal) of the
value to be retrieved from a collection internal to the Fields object.  The
collection object itself is not directly exposed.

It's probably more straightforward to think of Item as a method than a
property - the difference is a subtlety of the COM semantics which is
usually fairly unimportant.

> I also forgot which is the default COM property. Isn't it the name?

The default COM property depends on the definition of each interface.  For
the ADO Fields collection object, the default property is "Item".  For the
Recordset object, the default property is "Fields".  Thus
MyRecordSet("Name") in a client language which supports default COM
properties actually translates to MyRecordSet.Fields.Item("Name").

As far as I can tell, MysterX doesn't currently support default properties
(but I'm not a MysterX expert).  However, that doesn't affect the issue of
whether MysterX can access properties that expect parameters.  Currently,
MysterX doesn't publish an external function that allows this, although the
internal native (C) property accessor function may allow it - I'll be
checking that out a bit later, thanks to some help from Paul.

Anton