Lenspec

Lenspec can be used in combination with numeric formal parameters of type long or number. If specified along with an in or inout parameter, the actual parameter is used as length specification for the next string or dstring parameter on the left. If specified along with an inout or out parameter, the actual parameter variable is used as length specification for the next left string parameter.

Formal in parameters declared with the lenspec modifier allow actual parameters to be 0 or STRING_COMPLETE. If one of these values is used, Silk Performer's runtime calculates the actual length of the next string or dstring parameter on the left and sets this parameter accordingly.

The length of a BDL string variable usually is the number of characters before the first zero termination character. If the string variable is specified using the bin() operator, the binary length of the string variable is used.

注: The validity of the lenspec semantics is always limited to the next string or dstring parameter on the left, no matter if its semantics could be applied or not.

Example

dll "some.dll"
    "Send"
      function Send(sData : in string,
                     nDataLen : in number lenspec optional);

dcltrans
  transaction TMain
  var
    s1 : string;
  begin
    s1 := "\h110022";
    // sData = "\h11", nDataLen = 1
    Send(s1);
    // sData = "\h110022", nDataLen = 3
    Send(bin(s1));
    // sData = "\h11", nDataLen = 1
    Send(s1, STRING_COMPLETE);
    // sData = "\h110022", nDataLen = 3
    Send(bin(s1), STRING_COMPLETE);
  end TMain;