Returns a reference to another script component in the same package (.wsc file).
value = createComponent(componentID) |
Values
- componentID
-
The unique identifier for the script component to create an instance of.
Remarks
By calling the createComponent method, you can include the functionality of another script component in the same file. For more details, see Referencing Another Script Component in the Same Package.
Example
The following example shows two script components in the same package. The first script component calls the second script component when its math method is called.
Note |
---|
A CDATA section is required to make the script in the <script> element opaque. For details, see Script Component Files and XML Conformance. |
Copy Code | |
---|---|
<package> <component id="component1"> <registration progid="component.FrontEnd"/> <public> <method name="math"/> </public> <script language="JScript"> <![CDATA[ function math(){ return createComponent("component2") } ]]> </script> </component> <component id="component2"> <registration progid="component.Math"/> <public> <method name="add"/> </public> <script language="JScript"> <![CDATA[ function add(n1, n2){ return n1+n2; } ]]> </script> </component> </package> |
After registering this package, you can use it as illustrated in the following commands:
Copy Code | |
---|---|
set o1 = CreateObject("component.FrontEnd") Set o2 = o1.math() msgbox(o2.add(4,5)) |