DID Defined Function

General Attributes

All DID Defined Functions have the following attributes:

Name, this attribute sets the name of the Function. The Model Developer uses this name in the Model Document. The name of the function should start with an uppercase character and can be followed by lowercase characters, uppercase characters, digits or underscores '_'.

Execute Function, the Execute Function attribute determines which operation is performed when a Model calls a DID Defined Function. Depending on the DID Module connection type this can be the name or full path of a program, an SQL query, a special value or something else. The Execute Function string that you enter here is stored in the DID. The content of the string is only verified during the execution of a Model. You should be very careful with what you enter here.

List of Formal Parameters, you can optionally define formal parameters for a Function. The formal parameters are used in the Execute Function. The individual parameters are defined similar as Fields. Field attributes that do not make sense when they are used in a parameter definition, such as SCREEN_FIELD or OFFSET are silently ignored.

Codepage, the codepage attribute sets the codepage for the Function. If you do not define the codepage, ITP will use the codepage defined in the DID Module, if any. The codepage attribute is used to translate the result and parameters. During Model execution, ITP determines the codepage of the system on which it runs. Parameters that are passed to the Execute Function are translated from the system codepage to the codepage defined in the Entry. The result that is yielded by the Execute Function is translated from the codepage defined in the Entry to the codepage used by the system.
ITP uses sensible defaults for the codepage value. You should only set the codepage attribute if you experience problems.

Function Result, a function has a single result. Technically, you could view a Function as an Entry that only has a single Field. Entries and Functions however differ conceptually and in their practical use in a Model Document. Field attributes that do not make sense when they are used in a Function result definition, such as SCREEN_FIELD or OFFSET are silently ignored.

Local Connection attributes

Functions in a Local Connection DID Module have the following attributes:

Calling Convention, in Local Connection DID Modules you can also specify a calling convention for a Function. The calling convention can have values DLL16, DLL32, PROGRAM. The calling convention determines how the Execute Function is started.
When you use the calling convention attribute in other connection type DID Modules it is silently ignored.

Grammar

did-defined-function-definition ::=
DEFINE_DID_FUNCTION
NAME function-name
function-attribute-sequence
[ function-parameters ]
function-result 
END_DEFINE_DID_FUNCTION
function-attribute-sequence ::=
execute-function
[ local-connection-function-attributes ]
[ function-codepage ]
execute-function ::=
EXECUTE_FUNCTION retrieval-name
local-connection-function-attributes ::=
function-calling-convention
function-calling-convention ::=
CALLING_CONVENTIONS calling-convention
function-codepage ::=
CODEPAGE codepage
function-parameters ::=
DEFINE_PARAMETERS formal-parameter-sequence END_DEFINE_PARAMETERS
formal-parameter-sequence ::=
field-sequence
function-result ::=
FUNCTION_RESULT field-def
Example
DEFINE_DID_FUNCTION
NAME Total_amount_customer
EXECUTE_FUNCTION ... (* *)
DEFINE_PARAMETERS
...
(* Here go the parameter definitions *)
...
END_DEFINE_PARAMETERS
FUNCTION_RESULT ... (* *)
END_DEFINE_DID_FUNCTION