Siebel VB Language Reference > Using Siebel VB > Declaring Procedures and Variables >

Declaring a Procedure


This topic includes information about how to use the Declare Procedure statement to declare a procedure in a module or in a dynamic link library (DLL). For more information about this statement and the format and arguments that you can use with it, see Declare Procedure Method.

Specifying the Data Type

You do one of the following to specify the data type for the value that a method returns:

  • End the method name with a type character.
  • Use the following clause:

    As funcType

Note the following:

  • If you do not specify a type, then the method that the Declare Procedure statement declares defaults to the data type variant.
  • To use a record argument, you use an As clause and a type that is already defined with the Type statement.
  • To use an array argument, you use empty parentheses after the argument. You do not specify an array dimension in the Declare Procedure statement.

Sequence Determines How You Must Declare Code

Siebel Tools compiles custom methods in alphabetical order. If you reference code in the current code before you define it, then you must use a declaration. For example, assume you create the following subroutines in the general declarations section:

Sub A
' Calling B
B
End Sub

Sub B
theApplication.RaiseErrorText "Sub B called"
End Sub

In this situation, compilation fails with the following message:

Unknown function: B

If you add the following statement before Sub A, then the code compiles and runs properly:

Declare Sub B

Calling External DLL Code

You can use the Pascal calling convention to write code that calls external DLL code. Siebel VB pushes the arguments on the stack from left to right. It uses the Far reference to pass these arguments, by default. You can write code that uses the following keywords when it calls external DLL code:

  • ByVal. Passes a value through a variable. Note the following:
    • You must specify ByVal before you specify the argument that it modifies.
    • If you apply ByVal to a numeric data type, then Siebel VB passes the argument through a variable, not through a reference.
    • If you apply ByVal to a string data type, then Siebel VB passes the byFar pointer to the string data. It uses the byFar pointer to pass a string to a string descriptor, by default.

      For more information, see Pass Values Through Reference.

  • Any. Passes a value of any datatype. If you use Any for an argument, then Siebel VB does not examine the type of this argument. It does examine the type of any other argument that you do not specify as type Any. It uses the Far reference to pass the argument unless you specify the ByVal keyword. If you specify the ByVal keyword, then it does one of the following:
    • Numeric data. Places the value on the stack.
    • String data. Sets the pointer to the string.

      The external DLL code must determine the type and size of the value.

If Siebel VB uses ByVal to pass a null string, then the external code receives a nonNULL character of 0. To send a NULL pointer, you must declare the argument as ByVal As Any, and then call the code with an argument of 0.

Siebel VB Language Reference Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Legal Notices.