For example,you could create a function called open the application that loads a GUI map file,starts the application,and logs into the system, or resets the main window if the application is already open. A function can be called from anywhere in a test script. Since it is already compiled,execution time is accelerated. For instance, suppose you create a test that opens a number of files and checks their contents. Instead of recording or programming the sequence that opens the file several times, you can write a function and call it each time you want to open a file.
Function Syntax
A user-defined function has the following structure:
[class] function name([mode]parameter.....)
{
declarations;
statements;
}
Class: The class of a function can be either static or public. A static function is available only to the test or module within which the function was defined. Once you execute a public function,it is available to all tests,for as long as the test containing the function remains open.
This is convenient when you want the function to be accessible from called tests. However,if you want to create a function that will be available to many tests, you should place it in a compiled module. The functions in a compiled module are available for the duration of the testing session.If no class is explicitly declared, the function is assigned the default class,public.
Parameters: Parameters need not be explicitly declared. They can be of mode in,out,or inout. For all non-array parameters,the default mode is in. For array parameters,the default is inout. The significance of each of these parameters types is as follows:
in: A parameter that is assigned a value from outside the function.
out: A parameter that is assigned a value from inside the function.
inout: A parameter that can be assigned a value from outside or inside the function
A parameter designated as out or inout must be a variable name,not an expression. When you call a function containing an out or an inout parameter,the argument corresponding to that parameter must be a variable,and not an expression.For example,consider a user-defined function with the following syntax:
function get_date(out today_date) {....}
Proper usage of the function call would be
get_date(todays_date);
Illegal usage of the function call would be
get_date(date[i]);or get_date("Todays date is" & todays_date);
because both contains expressions.




