I have a JavaScript environment using IActiveScript and friends (via
COM interop). At one point, the JavaScript passes me a function as a
parameter to an object that has been inserted into the JavaScript
using AddNamedItem.
When I look at this object and ask it for its type, it says it is a
System.__ComObj ect. What I want to do is invoke this function in the
environment that I have using the engine I have instantiated. Is there
a way to do this?
Thanks,
Nathan 4 3217
Nathan,
You should be able to invoke the default member of the object in order
to invoke the method through reflection. IIRC, when a function is passed to
you, it is passed as an object with an IDispatch interface implementation
with the default method (with dispid = 0) being how you would call the
function.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Nathan Baker" <na*****@vt.edu wrote in message
news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
>I have a JavaScript environment using IActiveScript and friends (via
COM interop). At one point, the JavaScript passes me a function as a
parameter to an object that has been inserted into the JavaScript
using AddNamedItem.
When I look at this object and ask it for its type, it says it is a
System.__ComObj ect. What I want to do is invoke this function in the
environment that I have using the engine I have instantiated. Is there
a way to do this?
Thanks,
Nathan
Thanks a bunch, Nicholas. It worked exactly like you said.
For posterity, here's the code. "command" is the command passed in
from JavaScript and stored as an object, and jsData is some other
stuff passed in from javascript :
==
Type t = typeof(stdole.I Dispatch);
t.InvokeMember( "",
System.Reflecti on.BindingFlags .InvokeMethod,
null,
command,
new object[] { jsData });
==
Passing the null string for the first parameter invokes the default
method (as mentioned in the documentation).
Thanks again for pointing me in the right direction.
Nathan
On May 31, 4:39 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
Nathan,
You should be able to invoke the default member of the object in order
to invoke the method through reflection. IIRC, when a function is passed to
you, it is passed as an object with an IDispatch interface implementation
with the default method (with dispid = 0) being how you would call the
function.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om
"Nathan Baker" <nath...@vt.edu wrote in message
news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
I have a JavaScript environment using IActiveScript and friends (via
COM interop). At one point, the JavaScript passes me a function as a
parameter to an object that has been inserted into the JavaScript
using AddNamedItem.
When I look at this object and ask it for its type, it says it is a
System.__ComObj ect. What I want to do is invoke this function in the
environment that I have using the engine I have instantiated. Is there
a way to do this?
Thanks,
Nathan
Nathan,
You probably don't need the type of IDispatch, rather, you can just call
command.GetType ().
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Nathan Baker" <na*****@vt.edu wrote in message
news:11******** *************@h 2g2000hsg.googl egroups.com...
Thanks a bunch, Nicholas. It worked exactly like you said.
For posterity, here's the code. "command" is the command passed in
from JavaScript and stored as an object, and jsData is some other
stuff passed in from javascript:
==
Type t = typeof(stdole.I Dispatch);
t.InvokeMember( "",
System.Reflecti on.BindingFlags .InvokeMethod,
null,
command,
new object[] { jsData });
==
Passing the null string for the first parameter invokes the default
method (as mentioned in the documentation).
Thanks again for pointing me in the right direction.
Nathan
On May 31, 4:39 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
>Nathan,
You should be able to invoke the default member of the object in order to invoke the method through reflection. IIRC, when a function is passed to you, it is passed as an object with an IDispatch interface implementation with the default method (with dispid = 0) being how you would call the function.
-- - Nicholas Paldino [.NET/C# MVP] - m...@spam.guard .caspershouse.c om
"Nathan Baker" <nath...@vt.edu wrote in message
news:11******* *************** @q75g2000hsh.go oglegroups.com. ..
>I have a JavaScript environment using IActiveScript and friends (via
COM interop). At one point, the JavaScript passes me a function as a
parameter to an object that has been inserted into the JavaScript
using AddNamedItem.
When I look at this object and ask it for its type, it says it is a
System.__ComObj ect. What I want to do is invoke this function in the
environment that I have using the engine I have instantiated. Is there
a way to do this?
Thanks,
Nathan
Nicholas,
I figured that was probably the case, but I wasn't sure, so I went
ahead and took the safe route :)
Thanks again,
Nathan
On Jun 1, 2:56 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
Nathan,
You probably don't need the type of IDispatch, rather, you can just call
command.GetType ().
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om
"Nathan Baker" <nath...@vt.edu wrote in message
news:11******** *************@h 2g2000hsg.googl egroups.com...
Thanks a bunch, Nicholas. It worked exactly like you said.
For posterity, here's the code. "command" is the command passed in
from JavaScript and stored as an object, and jsData is some other
stuff passed in from javascript:
==
Type t = typeof(stdole.I Dispatch);
t.InvokeMember( "",
System.Reflecti on.BindingFlags .InvokeMethod,
null,
command,
new object[] { jsData });
==
Passing the null string for the first parameter invokes the default
method (as mentioned in the documentation).
Thanks again for pointing me in the right direction.
Nathan
On May 31, 4:39 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
Nathan,
You should be able to invoke the default member of the object in
order
to invoke the method through reflection. IIRC, when a function is passed
to
you, it is passed as an object with an IDispatch interface implementation
with the default method (with dispid = 0) being how you would call the
function.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om
"Nathan Baker" <nath...@vt.edu wrote in message
>news:11******* *************** @q75g2000hsh.go oglegroups.com. ..
I have a JavaScript environment using IActiveScript and friends (via
COM interop). At one point, the JavaScript passes me a function as a
parameter to an object that has been inserted into the JavaScript
using AddNamedItem.
When I look at this object and ask it for its type, it says it is a
System.__ComObj ect. What I want to do is invoke this function in the
environment that I have using the engine I have instantiated. Is there
a way to do this?
Thanks,
Nathan
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nick Coghlan |
last post by:
GvR has commented that he want to get rid of the lambda keyword for Python 3.0.
Getting rid of lambda seems like a worthy goal, but I'd prefer to see it dropped
in favour of a different syntax, rather than completely losing the ability to
have anonymous functions.
Anyway, I'm looking for feedback on a def-based syntax that came up in a recent
c.l.p discussion:...
|
by: Greg Swindle |
last post by:
Hello,
I have a question about how prototyping relates to variables and their
scope.
Given the following code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var ParentObject = function()
{
var objectName = "ParentObject";
|
by: Timothy Madden |
last post by:
Hello all.
I program C++ since a lot of time now and I still don't know this simple
thing: what's the problem with local functions so they are not part of
C++ ?
There surely are many people who will find them very helpfull. gcc has
them as a non-standard option, but only when compiling C language code,
so I'm afraid there might be some obscure reason why local functions are
not so easy to be dealt with in C++, which I do not yet know.
|
by: ged |
last post by:
Hi,
i am a oo (c#) programmer, and have not used javascript for a while and
i cant work out how javascript manages its references. Object
References work for simple stuff, but once i have an object collection
and stanrd using it it starts to fall apart.
Clearly there is something about javascript's usage of passing "By ref"
that i am not getting. i have had a look on the web and found some
examples, but i cant see why my code does not...
|
by: Jake Barnes |
last post by:
Using javascript closures to create singletons to ensure the survival
of a reference to an HTML block when removeChild() may remove the last
reference to the block and thus destory the block is what I'm hoping to
achieve.
I've never before had to use Javascript closures, but now I do, so I'm
making an effort to understand them. I've been giving this essay a
re-read:
http://jibbering.com/faq/faq_notes/closures.html
| |
by: Emre Sevinc |
last post by:
Take a look at the following snippet:
<html>
<head>
<script>
function add(elementId) {
var container = document.getElementById(elementId);
for (var i = 0; i < 10; i++) {
var elt = document.createElement('div');
elt.innerHTML = "" + i;
|
by: Maxim Veksler |
last post by:
Hello,
I'm new on this list and in python.
It seems python has some interesting concept of "ad hoc" function
which I'm trying to understand without much success.
Take the following code for example:
"""
.... return lambda x: x + n
|
by: marss |
last post by:
Maybe anyone know good free online JavaScript knowledge test? This not
exactly a system for testing online required - it may be simply list
of questions with variants of answers (I have to prepare tests for
learners and I need something to be taken as basis).
I was able to find only this (http://www.w3schools.com/js/
js_quiz.asp), but I need more.
Thanks,
Mykola
|
by: MartinRinehart |
last post by:
I've written a short article explaining closures in JavaScript. It's
at:
http://www.martinrinehart.com/articles/javascript-closures.html
I think I've understood. I look forward to your constructive critique.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |