 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Andrew Ayre Guest
|
Posted: Tue Aug 30, 2005 3:09 pm Post subject: How to use AddObject in Microsoft Scripting Control |
|
|
Can anyone point me in the direction of C++ examples, tutorials, etc. on how
to use AddObject? I have the scripting control working but I cannot figure
out how to allow the script access to parts of my application. Thanks.
Andy
[email]andy (AT) britishideas1965 (DOT) com[/email]
Remove year to reply. Please reply to the newsgroup.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Sep 06, 2005 5:05 am Post subject: Re: How to use AddObject in Microsoft Scripting Control |
|
|
"Andrew Ayre" <andy (AT) nospam (DOT) com> wrote
| Quote: | Can anyone point me in the direction of C++ examples, tutorials, etc.
on how to use AddObject? I have the scripting control working but I
cannot figure out how to allow the script access to parts of my
application. |
Which AddObject() method are you referring to exactly? Please be more
specific.
Gambit
|
|
| Back to top |
|
 |
Andrew Ayre Guest
|
Posted: Tue Sep 06, 2005 7:30 pm Post subject: Re: How to use AddObject in Microsoft Scripting Control |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote
| Quote: |
"Andrew Ayre" <andy (AT) nospam (DOT) com> wrote in message
news:43147675 (AT) newsgroups (DOT) borland.com...
Can anyone point me in the direction of C++ examples, tutorials, etc.
on how to use AddObject? I have the scripting control working but I
cannot figure out how to allow the script access to parts of my
application.
Which AddObject() method are you referring to exactly? Please be more
specific.
Gambit
|
I want the scripts to be able to access values and functions in my
application so that the scripts can be used to extend the application. I
read some things online that indicated calling AddObject to register an
Automation Function would do the trick. I then did some searching on
Automation Objects and only found examples in Visual Basic or Delphi, not
C++ and suitable for C++ Builder. I was hoping someone somewhere would point
me to a skeleton application that shows how this can be achieved. Thanks!
Andy
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Sep 06, 2005 9:05 pm Post subject: Re: How to use AddObject in Microsoft Scripting Control |
|
|
"Andrew Ayre" <andy (AT) nospam (DOT) com> wrote
| Quote: | I want the scripts to be able to access values and functions in
my application so that the scripts can be used to extend the
application.
|
That much was already understand from your original post. You did not
answer my question. Which SPECIFIC interface(s) that has the AddObject()
method are you trying to work with in your code? Again, please provide
SPECIFIC details.
| Quote: | I read some things online that indicated calling AddObject to
register an Automation Function would do the trick.
|
I do not know what you read online, but there is no AddObject() method for
accomplishing that. What you should be doing is the following:
1) derive a class from the IActiveScriptSite interface
2) Use CoCreateInstance() to instantiate an instance of the IActiveScript
interface using the CLSID of the desired scripting engine that you want to
use to parse script code with. You can use CoCreateInstance() to
instantiate an instance of the ICatInformation interface and then call its
EnumClassesOfCategories() method to enumerate the installed engines,
specifying CATID_ActiveScriptParse as the category.
3) query the IActiveScript for the IActiveScriptParse interface
4) call the IActiveScriptParse::InitNew() method
5) call the IActiveScript::SetScriptSite() method, passing it an instance of
your IActiveScriptSite-derived class.
6) call the IActiveScript::AddNamedItem() method for each named item that
you want to expose access to
7) call the IActiveScript::SetScriptState() method, specifying
SCRIPTSTATE_CONNECTED
With all of this in place, you can then pass script code to the
IActiveScriptParse::ParseScriptText() method when needed. When the script
encounters a named item that you specified with the
IActiveScript::AddNamedItem() method earlier, the script triggers the
IActiveScriptSite::GetItemInfo() method of your derived class. The
GetItemInfo() method can then return the IUnknown and/or ITypeInfo interface
pointers for the appropriate Automation object that you have designed to
manage the specified named item.
For instance, if you had the following VBScript code:
If App.SomeProp = True then
App.DoSomething
End If
You can create an Automation object for your project that has a Boolean
property named SomeProp and a method named DoSomething. The Automation
object has access to your application's internal data and such. Then
instantiate an instance of the Automation object at runtime, specify an item
named 'App' to IActiveScript::AddNamedItem(), and then have
IActiveScriptSite::GetItemInfo() return the IUnknown and ITypeInfo interface
pointers for the Automation object whenever the script needs to access an
item named 'App'.
Gambit
|
|
| Back to top |
|
 |
Andrew Ayre Guest
|
Posted: Wed Sep 07, 2005 5:36 pm Post subject: Re: How to use AddObject in Microsoft Scripting Control |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote
| Quote: |
"Andrew Ayre" <andy (AT) nospam (DOT) com> wrote in message
news:431dee21$1 (AT) newsgroups (DOT) borland.com...
I want the scripts to be able to access values and functions in
my application so that the scripts can be used to extend the
application.
That much was already understand from your original post. You did not
answer my question. Which SPECIFIC interface(s) that has the AddObject()
method are you trying to work with in your code? Again, please provide
SPECIFIC details.
|
I don't know much about ActiveX, so all I know so far is if I drop the
Microsoft Scripting Control ActiveX component onto my form, the resultant
object, which is a TScriptControl, implements an AddObject function. I did a
search on google groups for "microsoft scripting control addobject" and
there are some examples of it's use but for different languages. I'm not
sure what other AddObject functions there could be in relation to this
problem, but I'm sure I will run into them along the way.
Thanks for the detailed info! :)
Andy
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|