Declares a method.
<method name="methodName" internalName="functionName" dispid=dispID> [<parameter name="parameterID"/>] </method>
Tip In XML, you can implement elements that have no content (such as the <method> element) by closing the element with />.
A method is implemented as a procedure (function or subroutine) in a separate <script> element. The <method> element maps the name of the method to the procedure used to implement it.
You can optionally declare the parameters for your method. Doing so is not required, but exposes parameter information if you generate a type library for your script component (see Creating a Script Component Type Library).
The following script component fragment defines two methods (factorial and random). The random method includes definitions for its parameters, and binds to a function called getRandomNumber.
Note A CDATA section is required to make the script in the <script> element opaque. For details, see Script Component Files and XML Conformance.
<public> <method name="factorial"/> <method name="random" internalName="getRandomNumber"> <parameter name="upperBound"> <parameter name="seed"> </method> </public> <script language="VBScript"> <![CDATA[ Function factorial(n) If isNumeric(n) Then If n <= 1 Then factorial = 1 Else factorial = n*factorial(n-1) End If Else factorial = -2 ' Error code. End If End Function Function getRandomNumber(upperBound, seed) upperBound = CInt(upperBound) Randomize getRandomNumber = Cint(upperBound * Rnd(seed) + 1) End Function ]]> </script>
<event> Element | <property> Element | Exposing Events | Exposing Methods | Exposing Properties