GetString Function

Action

Extracts a substring starting at a specified position in a specified source string.
注: This function can be used to access pointers.

Include file

Kernel.bdh

Syntax

GetString( in  sSource   : string,
           in  nPos      : number,
           out sDest     : string,
           in  nDestSize : number ): boolean;

Return value

  • true if successful

  • false = string to copy terminated or failure

Parameter Description
sSource Source string
nPos Specifies the position to copy from in sSource, where the first position is 1 (not 0)
sDest Destination string
nDestSize Maximum number of characters to copy
注: If nMaxLen extends beyond the end of sSource, the actual length of substring sValue is adjusted downward to stop at the end of sSource.

Example

dcltrans
  transaction TGetString
  const
    SIZE_STRUCT := 32;
  var
    myBDLstring : string(SIZE_STRUCT);
    sString     : string(9);
    bOk         : boolean;
  begin
    SetString(myBDLstring, 22, "hello");
    // Copy a string from myBDLstring starting at position 22
    // into sString and thereby (through mapping)get
    // the element myString in Struct1
    bOk := GetString(myBDLstring, 22, sString,STRING_COMPLETE);
    write("myString = "); write(sString); writeln;
  end TGetString;

Output

myString = hello