Passing parameters to the CallScript method
This topic describes how to use the
different signatures of the CallScript
method to pass data
from one script to another.
The example uses two different Functional Test scripts:
-
TheCaller
, which calls another script and passes parameters -
TheCalled
, which receives the parameters and prints them toSystem.Console
-
TheCaller
script uses two different versions of theCallScript
method: - Without additional parameters: This is the default usage of the
CallScript
method, which will execute the specified script.CallScript("TheCalled");
- With additional object array parameter: An array of objects is
used to pass different object type parameters to the called script.
Dim ObjdataToPass as Object() ... CallScript("TheCalled",ObjdataToPass)
The Caller
script was recorded as follows:
Public Class TheCaller Inherits TheCallerHelper
' Script Name : TheCaller
' Generated : Dec 17, 2005 8:47:45 PM
' Description : Functional Test Script
' since 2005/12/17
' author Administrator
Public Function TestMain (ByVal args() As Object)
CallScript("TheCalled")
Dim DataToPass(3)As String
DataToPass(0) = "This"
DataToPass(1) = "is"
DataToPass(2) = "really"
DataToPass(3) = "cool!"
CallScript("TheCalled",DataToPass)
Dim ObjdataToPass(3)As Object
ObjdataToPass(0) = new String("Thought the previous was cool?")
ObjdataToPass(1) = "Take this one!"
ObjdataToPass(2) = new Float(0.02)
ObjdataToPass(3) = new Integer(4711)
CallScript("TheCalled",ObjdataToPass)
End Function
End Class
TheCalled script uses a simple loop to print the received parameters to
System.Console
:
Public Class TheCalled Inherits TheCalledHelper
' Script Name : TheCalled
' Generated : Dec 17, 2005 8:48:12 PM
' Description : Functional Test Script
' since 2005/12/17
' author Administrator
Public Function TestMain (ByVal args() As Object)
If args.Length < 1 Then
System.Console.WriteLine("There were "+args.Length+" args. Less than expected!")
Return
Else
System.Console.WriteLine( "There were: "+args.Length+" args")
End If
Dim I As Integer
For I = 0 To args.Length - 1
System.Console.WriteLine( " arg["+I+"] = " + args(I) .ToString())
Next
End Function
End Class