SetShort Function

Action

Copies a short value (2-byte signed integer value) into a data structure at a specified position. You must declare a BDL string before using this function.

Include file

Kernel.bdh

Syntax

SetShort( inout sString    : string,
          in    nPos       : number,
          in    nShort     : number,
          in    nByteOrder : number optional ) :boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sString BDL string corresponding to the data structure
nPos Insert position in the BDL string, where the first position is 1 (not 0)
nShort Short value
nByteOrder

Specifies the byte order that is applied when a value is set (optional). This parameter can be one of the following:

  • OPT_LITTLE_ENDIAN. Microsoft byte order (default).

  • OPT_BIG_ENDIAN. Network, Apple, Java byte order.

Example

dcltrans
  transaction TSetShort
  const
    SIZE_STRUCT := 32;
  var
    myBDLstring : string(SIZE_STRUCT);
    bOk         : boolean;
  begin
    // Set a 2-byte signed integer value at position 2
    // in the BDL string myBDLstring and thereby (through mapping) 
set
    // the element myShort in Struct1
    bOk := SetShort(myBDLstring, 2, -12);
    if bOk then
      write("myShort successfully set to -12"); writeln;
    else
      write("error setting myShort"); writeln;
    end;
  end TSetShort;

Output

myShort successfully set to -12