Declares a function or a test case function.
[scope] [testcase] [return-type] function-id([arguments]) statements [appstate]
|scope||Optional: Either public (the default) or private. Private declarations are available only in the file in which they occur. Public declarations can be accessed from other files through the use statement.|
|testcase||Optional: Indicates that this function definition is a logical sub-component within a Silk Test Classic script. See Exception Handling in Test Cases below.|
|return-type||Optional: The data type of the value returned by the function, or void (the default) if the function does not return a value.|
|function-id||An identifier that specifies the name of the function.|
|arguments||Optional: A list of the arguments that the function expects. See Specifying Arguments below.|
|statements||The statements that make up the body of the function; they tell the compiler what actions you want the function to perform.|
|appstate||Optional: Indicates an application state, which is typically used to put an application into the state it should be in at the start of a test case. Followed by an identifier that specifies the name of the application state being declared. See Appstate Declaration for an example and more information.|
A function is a group of 4Test statements that accomplish a discrete task. You can optionally pass arguments to a function and it can optionally pass back a return value.
4Test lets you use a function before you declare it.
In addition to declaring functions, you can call functions in DLL files using the dll declaration.
Silk Test Classic automatically performs special exception handling in test cases. If your code does not explicitly handle an exception, Silk Test Classic logs the error in the results file and exits the test case, but does not halt the script. You can also specify your own exception handling behavior for a test case, which overrides the default Silk Test Classic exception handling behavior.
When you write the argument list for a function, the required arguments appear first in the list, followed by the optional arguments. Separate arguments with a comma.
[pass-mode] data-type identifier [null] [optional]
|pass-mode||Optional: Either in (default), out, or inout. Specifies whether the argument is passed into the function, passed out of the function, or both. See Argument Pass Modes for more information.|
|data-type||The data type of the argument.|
|identifier||The name of the argument.|
|null||Optional: Indicates that the argument can contain a NULL value. If omitted, the default is that the argument cannot be NULL. If an argument is NULL and you have not explicitly allowed it to be NULL, Silk Test Classic raises an exception.|
|optional||Optional: Indicates that the argument is optional. If an optional argument has not been passed in, its value will be null on entry to the function. If you omit an optional argument, you may also omit any arguments that follow the optional argument.|