> for example, if I have a TByteArray and I want to get bytes 4 and 5 and
> convert them to a word, how do I go about doing that?
> 
> In Jade the code looks like:
> 
> myArray[4 : 5].Integer;
> 
> Do I need to defined record types of the various sizes I need, chuck the
> bytes into there and convert?
> 

var
  W :Word;
  MyArray :array[0..1] of Byte;
begin
  MyArray[0] := 1;
  MyArray[1] := 2;

  // MyArray[1] is MSB
  W := (PWord(@MyArray[0]))^;
  showmessage(inttostr(W));

  // MyArray[0] is MSB
  W := (MyArray[0] SHL 8) + MyArray[1];
  showmessage(inttostr(W));
end;

--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to