If a method has input parameters and a return value, the Code Generation Engine appropriately creates the BDL calls for passing those parameters in and getting the return parameter. Therefore a method can have any combination of parameters and return values that can be accessed by the DotNet API functions (DotNetGetXX).
C# Code | BDL Script |
---|---|
[Transaction(Etranstype.TRANSTYPE_MAIN)] public string TMain(string s, int n) { return s + n.ToString(); } |
dcltrans transaction Tmain var sReturn : string; begin DotNetSetString(hVuser1,"stringvalue"); DotNetSetInt(hVuser1, 123); DotNetCallMethod(hVuser1,"TMain"); DotNetGetString(hVuser1, sReturn, sizeof(sReturn)); end; |
By default the return parameter is stored in a variable with the name xReturn, or sReturn for strings. You can give the variable a meaningful name by applying the SilkPerformer.BdlParameter attribute to your return type and passing the variable name as the first parameter (sConcatParam in the following example).
C# Code | BDL Script |
---|---|
[Transaction(Etranstype.TRANSTYPE_MAIN)] [return:BdlParameter("sConcatParam")] public string TMain(string s, int n) { return s + n.ToString(); } |
dcltrans transaction Tmain var sConcatParam : string; begin DotNetSetString(hVuser1,"stringvalue"); DotNetSetInt(hVuser1, 123); DotNetCallMethod(hVuser1,"TMain"); DotNetGetString(hVuser1, sConcatParam, sizeof(sConcatParam)); end; |
The ability to define a different name for the return variable is necessary for the Code Generation Engine to generate BDL code that passes values between function calls.