Siebel VB Language Reference > VB Language Reference >
This standard VB function transfers control to a subprogram or function.
Call subprogram_name [(argument_list)]
subprogram_name is the name of the subprogram or function to which control is to be passed.
The arguments, if any, to be passed to the subroutine or function
If a function, its output; if a subprogram, not applicable.
Use the Call statement to call a subprogram or function written in Basic or to call C procedures in a DLL. These C procedures must be described in a Declare statement or be implicit in the application. Make sure the DLL is present on every Siebel Server.
If a procedure accepts named arguments, you can use the names to specify the argument and its value. Order is not important. For example, if a procedure is defined as follows:
Sub mysub(aa, bb, optional cc, optional dd)
The following calls to this procedure are equivalent to each other:
call mysub(1, 2, , 4)
mysub aa := 1, bb := 2, dd := 4
call mysub(aa := 1, dd:= 4, bb := 2)
mysub 1, 2, dd:= 4
The syntax for named arguments is as follows:
argname := argvalue
where argname is the name for the argument as supplied in the Sub or Function statement and argvalue is the value to assign to the argument when you call it.
The advantage to using named arguments is that you do not have to remember the order specified in the procedure's original definition, and if the procedure takes optional arguments, you do not need to include commas (,) for arguments that you leave out.
The procedures that can use named arguments include:
- Functions defined with the Function statement.
- Subprograms defined with the Sub statement.
- Procedures declared with Declare statement.
- Many built-in functions and statements.
- Some externally registered DLL functions and methods.
Arguments are passed by reference to procedures written in Basic. If you pass a variable to a procedure that modifies its corresponding formal argument, and you do not want to have your variable modified (that is, if you need to retain the "before" value), enclose the variable in parentheses in the Call statement. This tells Siebel VB to pass a copy of the variable. (This is called passing by value.) Note, however, that generally passing by value is less efficient, and should not be done unless necessary.
When a variable is passed to a procedure that expects its argument by reference, the variable must match the exact type of the formal argument of the function. (This restriction does not apply to expressions or variants.)
When calling an external DLL procedure, arguments can be passed by value rather than by reference. This is specified in the Declare statement, the Call statement itself, or both, using the ByVal keyword. If ByVal is specified in the declaration, then the ByVal keyword is optional in the call. If present, it must precede the value. If ByVal was not specified in the declaration, it is illegal in the call unless the data type was unspecified in the declaration.
This example calls a subprogram named
CreateFile to open a file, write the numbers 1 to 10 in it, and leave it open. The calling procedure then checks the file's mode. If the mode is 1 (open for Input) or 2 (open for Output), the procedure closes the file.
Declare Sub CreateFile
Rem Put the numbers 1-10 into a file
Dim x as Integer
Open "c:\temp001" for Output as #1
For x = 1 to 10
Write #1, x
Dim filemode as Integer
Dim attrib as Integer
attrib = 1
filemode = FileAttr(1,attrib)
If filemode = 1 or filemode = 2 then