GetMem Function

Action

Copies a specified number of bytes from a specified position in a source string to a destination string.

Include file

Kernel.bdh

Syntax

GetMem( in    sSource   : string,
        in    nPosition : number,
        inout sDest     : string,        
        in    nLen      : number ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sSource Contains the string to copy from
nPosition Specifies the position to start copying from in sSource, where the first position in a string is 1 (not 0)
sDest Contains the destination string
nLen Length to copy

Example

dcltrans
  transaction TGetMem
  const
    SIZE_STRUCT := 32;
  var
    myBDLstring : string(SIZE_STRUCT);
    sString     : string(6);
    bOk         : boolean;
  begin
...
    // Copy sizeof(sString) = 6 bytes from myBDLString starting
    // at position 2 into sString and thereby (through mapping) get the
    // elements myShort and myLong in Struct1
    bOk := GetMem(myBDLstring, 2, sString, STRING_COMPLETE); 

    if bOk then
      write("myShort and myLong successfully retrieved"); writeln;
    else
      write("error getting myShort and myLong"); writeln;
    end;
  end TGetMem;

Output

myShort and myLong successfully retrieved