Siebel VB Language Reference > Language Overview > Conventions >

Named Arguments


When you call a subroutine or function that takes arguments, you usually supply values for those arguments by listing them in the order shown in the syntax for the statement or function. For example, suppose you define a function this way:

myfunction(id, action, value)

From the preceding syntax, you know that the function called myfunction requires three arguments: id, action, and value. When you call this function, you supply those arguments in the order shown. If the function contains just a few arguments, you can remember their order with ease. However, if a function has several arguments, and you want to be sure the values you supply are assigned to the correct arguments, use named arguments.

Named arguments are arguments that are identified by name rather than by position in the syntax. To use a named argument, use the following syntax:

namedarg:= value

Using this syntax for myfunction, you get:

myfunction id:=1, action:="get", value:=0

The advantage of named arguments is that you do not need to remember the original order as they were listed in the syntax, so the following function call is also correct:

myfunction action:="get", value:=0, id:=1

With named arguments, order is not important.

The area in which named arguments have a significant advantage is in calls to functions or subprograms that have a mix of required and optional arguments. Ordinarily, you need to use commas as placeholders in the syntax for the optional arguments that you do not use. However, with named arguments you can specify just the arguments you want to use and their values without regard to their order in the syntax. For example, if myfunction is defined as:

myfunction(id, action, value, Optional counter)

you can use named arguments as follows:

myfunction id:="1", action:="get", value:="0"

or

myfunction value:="0", counter:="10", action:="get", id:="1"

NOTE:  Although you can shift the order of named arguments, you cannot omit required arguments. Siebel VB functions and statements accept named arguments. The argument names are listed in the syntax for each statement and function.


 Siebel VB Language Reference
 Published: 18 June 2003