SetUShort Function

Action

Copies an unsigned short value (2-byte unsigned 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

SetUShort( 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 Unsigned 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 TSetUShort
  const
    SIZE_STRUCT := 32;
  var
    myBDLstring : string(SIZE_STRUCT);
    bOk         : boolean;
  begin
    // Set a 2-byte unsigned character at position 20
    // in the BDL string myBDLstring and thereby (through mapping) set
    // the element myUShort in Struct1
    bOk := SetUShort(myBDLstring, 20, 64000);
    if bOk then
      write("myUShort successfully set to 64000");writeln;
    else
      write("error setting myUShort"); writeln;
    end;
  end TSetUShort;

Output

myUShort successfully set to 64000