|Bookshelf Home | Contents | Index | PDF|
The data type of name determines the type of the return value. Use a type character as part of the name, or use the As funcType clause to specify the data type. Otherwise the default data type is variant. When calling the function, you need not specify the type character.
The arguments are specified as a comma-separated list of variable names. The data type of an argument can be specified by using a type character or by using the As clause. Record arguments are declared using an As clause and a type that has previously been defined using the Type statement. Array arguments are indicated by using empty parentheses after the argument. The array dimensions are not specified in the Function statement. Every reference to an array argument within the body of the function must have a consistent number of dimensions.
You specify the return value for the function name using the name = expression assignment, where name is the name of the function and expression evaluates to a return value. If omitted, the value returned is 0 for numeric functions and a null string ("") for string functions and vartype 0 (Empty) is returned for a return type of variant. The function returns to the caller when the End Function statement is reached or when an Exit Function statement is executed.
If you declare an argument as Optional, a procedure can omit its value when calling the function. Only arguments with variant data types can be declared as optional, and optional arguments must appear after the required arguments in the Function statement. The function IsMissing must be used to check whether an optional argument was omitted by the user or not. Named arguments are described under the Call statement heading, but they can be used when the function is used in an expression as well.
CAUTION: You cannot write your own functions or subprograms directly in the methods and events exposed in Siebel Tools. You can write functions and subprograms in the (general) (declarations) section of a given method script. However, if you want your routines to be available throughout the program, you can use the Application_PreInvokeMethod or an external DLL file as a central place to write them. For details, read Siebel Technical Notes #207 and #217.
If you create more than one function or subprogram in the (general) (declarations) section, be sure that any function or subprogram that may be called by other user-defined functions and subprograms appears before the procedure that calls it. Otherwise, you cannot compile your procedures.
This example declares a function that is later called by the main subprogram. The function performs a calculation on the value sent to it, thereby changing the value of the variable. For other examples, read Declare Statement, and the second example within GoTo Statement.
|Siebel VB Language Reference|