Defining Parameters

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).

Defining Parameters

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;
As you can see in the above example, DotNetSetXX functions are scripted for each method parameter. The values are default values that are suggested by the Add-On. The Code Generation Engine also scripts a DotNetGetXX function for the return value of the method. The following .NET parameter types are supported:
  • String
  • Byte
  • SByte
  • UIntPtr
  • UInt16
  • UInt32
  • UInt64
  • Int16
  • Int32
  • Int64
  • IntPtr
  • Decimal
  • Double
  • Single
  • Boolean
  • Object

Return Parameter

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).

Example for Return Parameter

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.