Code Examples
  Home arrow Code Examples arrow Coding a Custom Object with WSC
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Coding a Custom Object with WSC
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2009-03-31

    Table of Contents:
  • Coding a Custom Object with WSC
  • Adding code for the object methods
  • Adding objects and resources
  • Registering and using your component
  • Protecting your intellectual property

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Coding a Custom Object with WSC


    (Page 1 of 5 )

    In the previous tutorial of this series we used the Windows Component Wizard to create our own custom COM object file. We told the wizard how we wanted it configured and it output the basic XML file for us. Now it’s time to put some code into that file.Our object exposes some properties and methods, but it doesn’t actually do anything yet.  For that we need to add some scripting.  I’m not going to go into detail about how this code works exactly; you can just cut at paste it into the <script> section.  Make sure that the code is between the <![CDATA[ and the closing ]]>.  This is a method of commenting text in an XML file.  The file will not parse properly if this isn’t present.

    Dim FullName

    Dim Name

    Dim Path

    Dim Count

     

    Function get_FullName()

       get_FullName = FullName

    End Function

     

    Function put_FullName(newValue)

       FullName = newValue

    End Function

     

    Function get_Name()

       get_Name = Right(FullName, Len(FullName) - InStrRev(FullName, ""))

    End Function

     

    Function get_Path()

       get_Path = Left(FullName, InStrRev(FullName, ""))

    End Function

     

    Function get_Count()

       get_Count = GetItemCount(FullName)

    End Function

    First things first. We define a few variables to hold the property values in our script, and then we provide the necessary functions for retrieving and setting those property values.  Notice the special syntax that is used in naming these functions.  They begin with either “get” or “put” followed by an underscore, and then the name of the property as defined in the <public> section from earlier.

    The get function is called whenever an outside script requests the value of a property.  The put function is called whenever an outside script passes a value to be assigned to the property.  You may or may not need either or both of these functions, depending upon whether the property is read-only, write-only, or read-write.

    More Code Examples Articles
    More By Nilpo


     

    CODE EXAMPLES ARTICLES

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT