We distinguish between external and internal functions. External functions are the BDL functions that are readily available for use, like for example WebPageUrl. Internal functions are functions that are implemented within your script. Random variables can be used as parameters of internal and external functions. Both external and internal functions can also be used as parameters of other external and internal functions.
FunctionSection = "DCLFUNC" { Function }. Function = [ @DEPRECATED [ "(" NewFuncName ")" ] ] "FUNCTION" ident [ "(" TParList ")" ] [ ":" RType ] [FuncAttribute] [ "CONST" ConstDecl ] [ "VAR" VarDecl ] "BEGIN" StatSeq "END" [ ident ] ";". TParList = TParam { ";" TParam }. TParam = IdentList ":" PType PModifier. PType = ["ARRAY" | "LIST" "OF" ] "STRING" "(" number ")" | ["ARRAY" | "LIST" "OF" ] "NUMBER" | ["ARRAY" | "LIST" "OF" ] "BOOLEAN" | ["ARRAY" | "LIST" "OF" ] "FLOAT" | "SQL" | "FORM". PModifier = "allownull" | "optional" [ ":=" (signum | float | boolean | ident)]. RType = "STRING" "(" number ")" | "NUMBER" | "BOOLEAN" | "FLOAT". FuncAttribute = "<" FuncAttributeValue ">"
Section | Description |
---|---|
ident | The name of the function. |
ConstDecl | The declarations of the function constants. |
VarDecl | The declarations of the function variables. |
StatSeq | The statements of the function. |
FuncAttributeValue | Specifies attributes for the function. The following options are valid:
|
benchmark BenchmarkName use "kernel.bdh" const MAX_ARRAY := 5; // Definition of global variables: string, number, float, boolean, array var sa1 : array [MAX_ARRAY] of string init "string1", "string2", "string3", "string4", "string5" ; na1 : array [MAX_ARRAY] of number init 1,2,3,4,5 ; dclfunc function foo1 (psa1 : array of string; pna1: array of number; len : number):number var i : number; begin for i := 1 to len do Print(psa1[i]); Print(string(pna1[i])); end; end foo1; function Func1(p1: number; s: number optional): number var i, j: number; begin if s = 0 then j := 1 else j := s end; for i := 1 to p1 do j := j*i; end; Func1 := j; end Func1; function Func2(p1: number) var i, j: number; begin j := 1; for i := 1 to p1 do j := j*i; end; p1 := j; end Func2; function Func3 begin write( "TestFunc was sucessfull"); end Func3; dcluser user VirtUser transactions TestFunc : 1; // Transactions dcltrans transaction TestFunc var l, m: number; begin foo1(sa1,na1,MAX_ARRAY); l := Func1(10); m := Func1(l); Func2(l); Func3(); end TestFunc;