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 Tester scripts:

callScript("TheCalled");

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

callScript("TheCalled",dataToPass);

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

callScript("TheCalled",objdataToPass);

The Caller script was recorded as follows:

import resources TheCallerHelper;

/**
* Description : Functional Tester 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 : Functional Tester 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);
}
}

TheCalled script uses a simple loop to print the received parameters to System.out:

import resources.TheCalledHelper;

/**
* Description : Functional Tester 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 : Functional Tester 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]);
}
}
}

 

Terms of use | Feedback
(C) Copyright IBM Corporation 2002, 2004. All Rights Reserved.