BinSetlen Function

Action

Sets the actual data length of a string. The specified length must be within the range of 0 and StrSize().

注: Under normal circumstances the data length of a string variable is always set correctly by the runtime. However, some external functions might require manual interference in order to have the data length set correctly. This function can also be used for stripping a string to the specified length.

Include file

Kernel.bdh

Syntax

BinSetlen( in sString : string,
           in nNewLen : number ) : boolean;

Return value

  • true if the new data length could be set successfully

  • false otherwise

Parameter Description
sString String whose data length is set.
nNewLen Data length the string should be set to.

Example

dcltrans
  transaction TMain
  var
    sString : string;
  begin
    sString := "Hello world";
    BinSetlen(sString, 5);
     
Print(sString);
    Print("Strlen = " + string(Strlen(sString)));
    Print("Binlen = " + string(Binlen(sString)));
  end TMain;

Output

HelloStrlen = 5Binlen = 5