|
Create a WSC component part 2
In the first part of our tutorial on creating
our WSC component we created a skeleton for the component using
the WSC wizard , we will now add some functionality to the component
, register it and use the component .
Firstly , locate your component and open it with
notepad or a similar text editor and you will notice a whole
load of code has been created for you . We want to modify the
code between the <script language = "VBScript">
and the <script> tags . Change the code so it looks like
this
<script language="VBScript">
<![CDATA[
function SayHello()
MsgBox "Hello world sample component"
end function
]]>
</script>
figure 7 : our modified code
You will notice the code in the .wsc file is XML and that a
variety of information is present such as registration information.
Registering your component
Now we will register our component . The method I am using
is with Windows 2000 .
1/ : Locate the component in the directory / folder in which
you saved it .
2/ : Right click on the component and you will be presented
witha series of options figure 8 , select
register and click on it you should recieve a success message
. figure 9
Using our component
Now we will create an asp page and use our component , create
a new asp page and enter the following code .
<%
Dim greeting
'create an instance of the HelloWorld object
Set greeting = Server.CreateObject("HelloWorld.SayHello")
'display a greeting
greeting.SayHello
%>
Now save this and check this works correctly by opening your
page you should now see a message box with your message displayed
in it.
|