RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.Swap Function

Exchanges high order byte with the low order byte of an integer or word.

Pascal
procedure Swap(X);
C++
Swap( X);

In Delphi code, Swap exchanges the high-order bytes with the low-order bytes of the argument. X is an expression of type SmallInt, as a 16-bit value, or Word. This is provided for backward compatibility only.  

Delphi Examples: 

 

{
This example demonstrate use of the System Swap function to
exchange the high and low portions of a word.
}
procedure TForm1.Button1Click(Sender: TObject);
var
  W: Word;
begin
  W := Swap($1234);
  ShowMessage(Format('The swapped value of $1234 = $%x', [W]));
end;

 

Hi 

Lo

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!