Cómo pasar parámetros al método CallScript

En este tema se describe cómo utilizar las firmas diferentes del método CallScript para pasar datos de un script a otro.

El ejemplo utiliza dos scripts de Functional Tester distintos:

El script Caller se ha grabado de la siguiente manera:

Public Class TheCaller Inherits TheCallerHelper

      ' Script Name     : TheCaller
      ' Generated       : Dec 17, 2005 8:47:45 PM
      ' Description     : Functional Tester 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

El script TheCalled utiliza un bucle simple para imprimir los parámetros recibidos en System.Console:

Public Class TheCalled Inherits TheCalledHelper

      ' Script Name     : TheCalled
      ' Generated       : Dec 17, 2005 8:48:12 PM
      ' Description     : Functional Tester 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

Comentarios