GetUShort Function

Action

Retrieves an unsigned short value (2-byte unsigned integer value) from a specified data structure at a specified position. You must declare a BDL string before using this function.

Include file

Kernel.bdh

Syntax

GetUShort( in sBuffer    :string,
           in nPos       : number           
           in nByteOrder : number optional ): number;

Return value

unsigned short value

Parameter Description
sBuffer BDL string corresponding to the data structure
nPos Starting position in the BDL string, where the first position is 1 (not 0).
nByteOrder

Specifies the byte order that is applied when a value is retrieved (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 TGetUShort
  const
    SIZE_STRUCT := 32;
  var
    myBDLstring : string(SIZE_STRUCT);
    nShort      : number;
  begin
    ...
    // Retrieve a 2-byte unsigned character from position 20
    // in the BDL string myBDLstring and thereby (through mapping)
    // get the element myUShort in Struct1
    nShort := GetUShort(myBDLstring, 20);
    write("myUShort = "); write(nShort); writeln;
  end TGetUShort;

Output

myUShort = 189