Some way of "optional" return values for com object properties? 
Author Message
 Some way of "optional" return values for com object properties?

Hello!

I've created a com component with a parameterized property that
returns a Variant. The problem is that it should also be possible to
call this property like a method without return value, i.e. (in
JScript):
"val = object.property(param)"
and also
"object.property(param)"
when I'm not interested in the return value. However, in the second
case I get an error message that "the object doesn't support this
property or method", so obviously the JScript method call is not
mapped to my com function because of the missing return value
place-holder. Is there a way to make this work anyway?

I've read that midl doesn't allow the combination of [optional] and
[retval], and at least I found that it's no error to write this, but
it has no effect either. Yet I know that there must be a way to get
this work since the Scripting.Dictionary component, for instance, has
a property keys() that can be called without getting the return value
(which is quite senseless but it shows it's possible), i.e.
"dictionary.keys()"
instead of
"keys = dictionary.keys()"

Thx
Torsten



Mon, 28 Feb 2005 17:29:32 GMT  
 Some way of "optional" return values for com object properties?
Do you also need to assign to this property, as in

object.property(param) = newVal;

? If not, there is no reason to make it a property in the first place.
Just make it a method - both syntaxes you show are valid for methods.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hello!

> I've created a com component with a parameterized property that
> returns a Variant. The problem is that it should also be possible to
> call this property like a method without return value, i.e. (in
> JScript):
> "val = object.property(param)"
> and also
> "object.property(param)"
> when I'm not interested in the return value. However, in the second
> case I get an error message that "the object doesn't support this
> property or method", so obviously the JScript method call is not
> mapped to my com function because of the missing return value
> place-holder. Is there a way to make this work anyway?

> I've read that midl doesn't allow the combination of [optional] and
> [retval], and at least I found that it's no error to write this, but
> it has no effect either. Yet I know that there must be a way to get
> this work since the Scripting.Dictionary component, for instance, has
> a property keys() that can be called without getting the return value
> (which is quite senseless but it shows it's possible), i.e.
> "dictionary.keys()"
> instead of
> "keys = dictionary.keys()"

> Thx
> Torsten



Mon, 28 Feb 2005 23:47:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Comparisons with value returned from "signal".

2. Q: Return-values of system("...") calls

3. Raising "Invalid Property Values"

4. Opinions: A property of type "Object"?

5. COM: Accessing "parent" object

6. COM: Accessing "parent" object

7. "parameter not optional"

8. "Optional" arguments

9. Q : What is returned by "return;"

10. ATL COM Object in Java Script - "Object doesn't support this property or method"

11. Return a pointer to a nested COM object from a COM object method

12. COM Object returning COM Object Reference

 

 
Powered by phpBB® Forum Software