Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 14th, 2009, 04:11 AM
spot spot is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 8 spot User rank is Corporal (100 - 500 Reputation Level)spot User rank is Corporal (100 - 500 Reputation Level)spot User rank is Corporal (100 - 500 Reputation Level)spot User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 h 48 m 42 sec
Reputation Power: 0
Can WSC components share code?

Is it possible to have code that can be shared between components within a WSC? Something like this for example;

Code:
<package>

<component id='a'>
  <public>
    <property name="p"><get/></property>
  </public>
  <script language="VBScript">
    <![CDATA[
      Function get_p()
        get_p = Hello()
      End Function
    ]]>
  </script>
</component>

<component id='b'>
  <public>
    <property name="p"><get/></property>
  </public>
  <script language="VBScript">
    <![CDATA[
      Function get_p()
        get_p = Hello()
      End Function
    ]]>
  </script>
</component>

Function Hello()
  Hello = "Hello world"
End Function

</package>


Wrapping up the "Sub Hello()" code as a component would make it public.

What I want the ability to share code between components within the package without making the shared code public. Is that possible?

Regards.

Reply With Quote
  #2  
Old August 15th, 2009, 04:12 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,880 Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)  Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 8 h 47 m 8 sec
Reputation Power: 967
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Quote:
Originally Posted by spot
Wrapping up the "Sub Hello()" code as a component would make it public.
Enclosing a function in a component does not make it public. It must be declared public like this:
vb Code:
Original - vb Code
  1. <component>
  2.    <?component error="false" debug="false"?>
  3.    <public>
  4.        <method name="Hello">
  5.        </method>
  6.    </public>
  7. </component>
You can learn more by reading my three-part series on Windows Script Components.

Introducing Custom Objects with WSC

Creating a Custom Object with WSC

Coding a Custom Object with WSC
__________________
Don't like me? Click it.

Scripting problems? Windows questions? Ask the Windows Guru!

Stay up to date with all of my latest content. Follow me on Twitter!

Help us help you! Post your exact error message with these easy tips!

Last edited by Nilpo : August 15th, 2009 at 04:16 AM.

Reply With Quote
  #3  
Old August 15th, 2009, 05:45 AM
spot spot is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 8 spot User rank is Corporal (100 - 500 Reputation Level)spot User rank is Corporal (100 - 500 Reputation Level)spot User rank is Corporal (100 - 500 Reputation Level)spot User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 h 48 m 42 sec
Reputation Power: 0
Thanks Nilpo.

How do I reference the second component from the first one without making its properties public?

Say Component A uses Component B like this;

Code:
<?xml version="1.0"?>
<package>

<component id="A">
  <public>
    <property name="P"><get/></property>
  </public>

  <script language="VBScript">
  <![CDATA[
  Option Explicit

  Function get_P()
    Dim objB
    Set objB = CreateComponent("B")
    get_P = "Hello " & objB.P
  End Function

  ]]>
  </script>
</component>

<component id="B">

  <public>
    <property name="P"><get/></property>
  </public>

  <script language="VBScript">
  <![CDATA[
  Option Explicit

  Function get_P()
    get_P = "world"
  End Function

  ]]>
  </script>
</component>

</package>


Calling code:

Code:
<%
Dim strWscPath, objA

strWscPath = Server.MapPath("main.wsc")
Set objA = GetObject("script:" & strWscPath & "#A")
Response.Write(objA.P)
Set objA = Nothing
%>

Result: "Hello world".

But I can't get component A to use component B without making component B public.

Do you know if it is possible?

Thanks.

Reply With Quote
  #4  
Old August 15th, 2009, 10:12 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,880 Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)  Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 8 h 47 m 8 sec
Reputation Power: 967
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
To my knowledge this isn't possible. A component cannot see a method in another component unless it's exposed publicly. That's the nature of having a self contained object.

You can, however, have private methods within a single component.

Reply With Quote
  #5  
Old August 17th, 2009, 02:12 PM
spot spot is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 8 spot User rank is Corporal (100 - 500 Reputation Level)spot User rank is Corporal (100 - 500 Reputation Level)spot User rank is Corporal (100 - 500 Reputation Level)spot User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 h 48 m 42 sec
Reputation Power: 0
Thanks for the info Nilpo

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > Can WSC components share code?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek