Transmitindo Parâmetros para o Método callScript

Este tópico descreve como utilizar as diferentes assinaturas do método callScript para transmitir dados de um script para outro. O exemplo utiliza dois scripts diferentes do Teste Funcional:

callScript("TheCalled");

String[] dataToPass = new String[4];
...

callScript("TheCalled",dataToPass);

Object[] objdataToPass = new Object[4];
...

callScript("TheCalled",objdataToPass);

O script Caller foi gravado da seguinte forma:

import resources TheCallerHelper;

/**
* Description : Teste Funcional Script
* @author Administrator
*/

public class TheCaller extends TheCallerHelper
{
/**
* Script Name : <b>TheCaller</b>
* Generated : <b>Dec 17, 2002 8:47:45 PM</b>
* Modified : <b>Dec 17, 2002 8:47:45 PM</b>
* Description : Teste Funcional Script
* Original Host : WinNT Version 5.0 Build 2195 (Service Pack 2)
*
* @since 2002/12/17
* @author Administrator
*/
public void testMain (Object[] args)
{

callScript("TheCalled");

String[] dataToPass = new String[4];
dataToPass[0] = "this";
dataToPass[1] = "is";
dataToPass[2] = "really";
dataToPass[3] = "cool";

callScript("TheCalled",dataToPass);

Object[] objdataToPass = new Object[4];
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);
}
}

O script TheCalled utiliza um loop simples para imprimir os parâmetros recebidos para System.out:

import resources.TheCalledHelper;

/**
* Description : Teste Funcional Script
* @author Administrator
*/

public class TheCalled extends TheCalledHelper
{
/**
* Script Name : <b>TheCalled</b>
* Generated : <b>Dec 17, 2002 8:48:12 PM</b>
* Modified : <b>Dec 17, 2002 8:48:12 PM</b>
* Description : Teste Funcional Script
* Original Host : WinNT Version 5.0 Build 2195 (Service Pack 2)
*
* @since 2002/12/17
* @author Administrator
*/
public void testMain (Object[] args)
{
if (args.length < 1)
{
System.out.println( "Expected at least 1 arg, but I got: "+args.length);
return;
}
else
{
System.out.println( "Got: "+args.length+" args");
};

for (int i = 0; i < args.length; ++i)
{
System.out.println( " arg["+i+"] = "+args[i]);
}
}
}

 

Termos de uso | Feedback
(C) Copyright IBM Corporation 2002, 2004. Todos os Direitos Reservados.