April 26, 2024, 11:06:52 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Paying for tutorial.

Started by Shannara, January 21, 2007, 05:08:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Shannara

Ok, I have already messaged two people concerning this. However, they seem to be uber busy, so I will post here for a wider audience.

I am looking to pay (via paypal) for a complete tutorial on using the Microsoft Script Control. This is an ActiveX control that adds scripting to any language that can run ActiveX controls. It is commonly used in Visual Basic. The key element here, is the ability to use the .AddObject method, and having a vbs (visual basic script) file that makes use of that object. In other words, passing an Aurora class to the activex control, and being able to reference/use it from with/in a script.

Information concerning Microsoft Script Control (msscript.ocx) and be found in the following links:

Visual Basic: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=36716&lngWId=1

C++?: http://www.codeguru.com/cpp/com-tech/activex/controls/article.php/c5559/#more

http://www.codeproject.com/com/scriptdemo.asp

http://msdn.microsoft.com/msdnmag/issues/0600/visualprog/

http://www.microsoft.com/mind/0799/script/script.asp

http://support.microsoft.com/kb/184745

http://msdn2.microsoft.com/en-us/library/ms974586.aspx


This is the only thing that is preventing me from using Aurora for my needs, as my applications must have vbs scripting. If you are interested, please reply or PM me.
Love is staying up all night with a sick child, or a healthy adult.

Zen

Hmmm from looking at the SDK I can't seem to find the windows headers in which these interfaces are implemented in. I will have a go, although I havnt done COM before, its not a great deal different than normal OOP I guess. It will help me learn and I am quite interested in this myself.

Although I cannot promise I can get this to work and even if I can, I doubt it would be soon. But I will try and implement this as a custom control, I think it would be good this way.

Lewis

Shannara

Thank you for the response :)

Maybe, the following links will help with headers?


http://support.microsoft.com/kb/184904

http://com.it-berater.org/scripting.htm <- bottom of page
Love is staying up all night with a sick child, or a healthy adult.

Steven Picard

The problem is the AddObject is expecting a COM object with the IDispatch interface.  VisualBasic does so many thing automatically that this is not noticed.  I have only seen examples using AddObject for VB and Delphi.  However I did find an interesting post somewhere else on the matter that may be of some help (this follows along with the interface descriptions on this page: http://msdn.microsoft.com/msdnmag/issues/0600/visualprog/):

Quote
QuoteQuote:
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'.

http://www.borlandtalk.com/how-to-use-addobject-in-microsoft-scripting-control-vt1270.html