Harald,
There is no such easy way to "share" function code between component scripts I am aware of.
In my components I ended up with a script (a library) that has all the required functions implemented for all the components. The
component's DHTML page scripts call to the these functions. Basically, like "include" approach.
However, if you know for sure that some specific component(s) will be in the Configuration you can get a reference to the component
script and leverage the script functions (it is interpreted VB script after all).
Within your components' script you find that specific component (enumerate through cmiThis.Configuration.Instances collection) and
then just call that component script functions like: <component_instance_object>.Script.Function.
The best candidate for such specific component would be the "Base Component" instance. If you upgrade the component (create your own
version/revision of this component just modifying Microsoft script there) and add your own library functions to the component
script, you can use it anywhere else without much of problems. The Base Component instance must be in any configuration so you don't
have to worry about its existence. The call like [cmiThis.Script.]oPL.GetBaseInstance will give you the base component instance
reference.
--
Regards,
KM, BSquare Corp.
PS. You could "add" some generic function set to TD script itself but it would require some hacking for the toolkit. It is still
possible but I don't think you want to go this route because it may not worth the effort from legal point of view.
> Hello
>
> perhaps this is not the newsgroup for this kind of questions, but anyway
> it has something to do with windows xp embedded components.
>
> To reduce the footprint of a couple components for ramdisk i create
> prototypes of the orginal components by adding component DHTML and
> vbs scripts to disable dependencies for unwanted compomments (thanks to KM).
>
> An small example is appendend at the end of this mail.
>
> My Question :
> I like to share the code of functions like
>
> Private Function fCheckResources( oResources, aRes )
> Private Function fCheckDependencies( oDependencies, aDep )
>
> in an extra global component ( only containing libray functions ).
>
> In fact i want to call a generic function of another components vb-script
> ( here: by passsing an individual array "aDependencies" with componets to
> be disabled ).
>
> I cannot figure out how to call script function of another component or
> how to add something like global function which can be accessed amoung
> several components.
>
> If this approch can be solved it would be easier to maintain a set of
> library functions for components with component scripts.
>
> Perhaps another problem could also be solved:
>
> When I add my own script to a prototyped component the original
> ( sometimes encrypted ) script in no more excuted. It would be nice
> to find a method which executes the functions of the original
> component.
>
>
> Kind Regards
>
> Harald
>
>
>
>
>
> ############################################################################
> ####
>
> <%asp%>
> <%= ASP.Header %>
> <%= ASP.PropHandlers %>
>
>
> <h1> </h1>
> <p> </p>
>
> <table>
> <caption> </caption>
> <tr>
> <td><label for="oemNoActiveDs">Disable Active Directory
> Service:</label></td>
> <td><input type="checkbox" name="cmixDefPropHandler" checked="1"
> ID="oemNoActiveDS"></td>
> </tr>
> <tr>
> <td><label for="oemNoRemoteSPX">Disable Remote SPX:</label></td>
> <td><input type="checkbox" name="cmixDefPropHandler" checked="1"
> ID="oemNoRemoteSPX"></td>
> </tr>
> </table>
>
> <!-- Display custom properties -->
> <h3>Custom Properties</h3>
> <p>| <%= ASP.ShowSpan("cprops", False) %> |</p>
>
> <div id="cprops" style="display: none;">
> <table border="0" bgcolor="#E0E0E0">
> <caption>Custom Properties</caption>
> <thead>
> <tr>
> <th>Name</th>
> <th>Format</th>
> <th>Value</th>
> </tr>
> </thead>
> <% Dim oProp %>
> <% For Each oProp In ASP.Instance.Properties %>
> <tr valign="top">
> <td><b><%= oProp.Name %></b></td>
> <td><%= oProp.Format %></td>
> <td><%= vuVarToString(oProp.Value, 10) %></td>
> </tr>
> <% Next %>
> </table>
> </div>
>
> <!-- Display all resources -->
> <h3>Resources</h3>
> <p>| <%= ASP.ShowSpan("res", False) %> |</p>
>
> <div id="res" style="display: none;">
> <table border="0" bgcolor="#E0E0E0">
> <caption>Resources</caption>
> <tr>
> <th>Name</th>
> <th>DisplayName</th>
> <th>Disabled</th>
> </tr>
> <% Dim oRes
> For Each oRes In ASP.Instance.Resources %>
> <tr valign="top">
> <td><b><%= oRes.Name %></b></td>
> <td><%= oRes.DisplayName %></td>
> <td><%= oRes.Disabled %></td>
> </tr>
> <% Next %>
> </table>
> </div>
>
>
> <%= ASP.Footer %>
>
> ############################################################################
> ####
> ############################################################################
> ####
>
>
> '///////////////////////////////////////////////////////////////////////////
> /
> ' $Header:$
> ' Windows Embedded Shell configuration Script
> ' Version: 1.00
> ' Author: hjennerich
> ' Copyright (c) 1999-2001 Microsoft Corp. All Rights Reserved.
> '///////////////////////////////////////////////////////////////////////////
> /
>
> Option Explicit
>
> '//events fired as part of the processing of method calls on CMI objects
> ' Function cmiOnActivateInstance( oOldInstance )
> ' Function cmiOnConfigureRawHTML( )
> ' Sub cmiOnBeginCheckDependencies( dwFlags )
> ' Sub cmiOnEndCheckDependencies( dwFlags )
> ' Sub cmiOnBuild( dwFlags )
> ' Sub cmiOnEndBuild( dwFlags )
>
> Private Const cProcName = "El:RPC_Named_Service::"
>
> Private Const cVSGUID_Files = "{E66B49F6-4A35-4246-87E8-5C1A468315B5}"
> Private Const cVSGUID_RawDep = "{90D8E195-E710-4AF6-B667-B1805FFC9B8F}"
> Private Const cVSGUID_FBAGeneric= "{FB2B6E76-FCD6-4D60-85D5-83C17D853AE3}"
> Private Const cVSGUID_FBRegDLL = "{322D2CA9-219E-4380-989B-12E8A830DFFA}"
> Private Const cVSGUID_Service = "{5C16ED57-3182-4411-8EA7-AC1CE70B96DA}"
> Private Const cVSGUID_RegKey = "{2C10DB69-39AB-48A4-A83F-9AB3ACBA7C45}"
>
> ' Definitions found with CMIMGR.Wsf
> Private Const cGUID_ActiveDs = "{1B067695-9191-4EE5-8DED-2648B5925A95}"
> Private Const cGUID_RemoteSPX = "{6E87160E-51F7-455D-B198-762277B40269}"
>
> ' Definitions from .asp Script
> Private Const cNoActiveDs = "oemNoActiveDs" ' Active Directory Sevicw
> Private Const cNoRemoteSPX = "oemNoRemoteSPX"
> Private Const cNoNwLnk = "oemNoNwLnk"
>
> ' "Internet Authentication Service (IAS) and Remote Access Common Files"
> Private Const cGUID_IAS = "{7D442112-DE82-486F-BBAF-B4B7386967D8}"
> '"File Server For Macintosh Management Interface"
> Private Const cGUID_SFMAPI = "{059062A3-CEE5-47EE-9E5A-DA42B704EC4E}"
> '"Microsoft Visual C++ Run Time (Legacy)"
> Private Const cGUID_MSVCP50 = "{F81070E3-76B7-4017-A73C-AD46D9C0CDF6}"
> '"Dial-up Server for Windows - Hotfix Q318138"
> Private Const cGUID_NwLnkFwd = "{895B7938-B1A9-4B26-9E0F-EE0B6756FBC6}"
>
>
>
> Private aFiles: aFiles = Array( _
> Array( "nwlnkflt.sys" , cNoNwLnk ),_
> Array( "nwlnkfwd.sys" , cNoNwLnk ),_
>
> Private aDependencies : aDependencies = Array( _
> Array( cGUID_ActiveDs, cNoActiveDs ),_
> Array( cGUID_RemoteSPX, cNoRemoteSPX ))
>
> Private aResources : aResources = Array( _
> Array( "activeds.dll", cNoActiveDs ),_
> Array( "activeds.dll", cNoctiveDs ))
>
> Private Function fCheckDependencies( oDependencies, aDep )
> Dim oDep : Set oDep = Nothing
> Dim i
> Dim sDisabled, sTargetGUID
> fCheckDependencies = 0
>
> For Each oDep In oDependencies
> sTargetGUID = oDep.TargetGUID
> For i = 0 to UBound( aDep )
> If ( sTargetGUID = aDep(i)(0) ) Then
> oDep.Disabled = CBool( cmiThis.Properties(
> aDep(i)(1) ).Value )
> fCheckDependencies = fCheckDependencies + 1
> Exit For
> End If
> Next
> Next
> End Function
>
>
> Private Function fCheckResources( oResources, aRes )
> Dim i
> Dim oRes
> Dim sValue, sVSGUID
> fCheckResources = 0
>
> For Each oRes In oResources
> sVSGUID = oRes.ResourceTypeVSGUID
> sValue = ""
> Select Case sVSGUID
> ' Case cVSGUID_RegKey
> Case cVSGUID_FBRegDll
> If oRes.Properties.Exists("FilePath") Then
> sValue = oRes.Properties("FilePath").Value
> i = InstrRev( sValue, "\" )
> If ( i > 1 ) Then sValue = Mid( sValue, i + 1 )
> End If
> ' Case cVSGUID_Service
> Case cVSGUID_RawDep
> If oRes.Properties.Exists("Value") Then
> sValue = oRes.Properties("Value").Value
> End If
> Case cVSGUID_Files
> If oRes.Properties.Exists("DstName") Then
> sValue = oRes.Properties("DstName").Value
> End If
> ' Case cVSGUID_FBAGeneric
> ' Case Else
> End Select
> If ( sValue <> "" ) Then
> For i = 0 to UBound( aRes )
> If ( sValue = aRes(i)(0) ) Then
> oRes.Disabled = CBool( cmiThis.Properties(
> aRes(i)(1) ).Value )
> fCheckResources = fCheckResources + 1
> Exit For
> End If
> Next
> End If
> Next
> End Function
>
>
>
> Function cmiOnActivateInstance( oOldInstance )
> Const cProcEvent = "cmiOnActivateInstance"
> oPL.TraceEnter cProcName & cProcEvent ' //oPL - global object present
> in Platform Script
> cmiOnActivateInstance = False
> ' First call super
> If Not cmiSuper.cmiOnActivateInstance(Nothing) Then
> Exit Function
> End If
> Call fCheckResources( cmiThis.Resources, aResources )
> cmiOnActivateInstance = True
> oPL.TraceLeave cProcName & cProcEvent
> End Function
>
>
> Sub cmiOnBeginCheckDependencies( dwFlags )
> Const cProcEvent = "cmiOnBeginCheckDependencies"
> oPL.TraceEnter cProcName & cProcEvent ' //oPL - global object present
> in Platform Script
> Call fCheckDependencies( cmiThis.Dependencies, aDependencies )
> oPL.TraceLeave cProcName & cProcEvent
> End Sub
>
> ############################################################################
> ####
> ############################################################################
> ####
>
>
>
|