help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



[Overview][Constants][Types][Classes][Procedures and functions][Variables] Reference for unit 'System' (#rtl)

Swap

Swap high and low bytes/words of a variable

Declaration

Source position: line 0

function swap(

  X: Word

):Word;

function Swap(

  X: Integer

):Integer;

function swap(

  X: LongInt

):LongInt;

function Swap(

  X: Cardinal

):Cardinal;

function Swap(

  X: QWord

):QWord;

function swap(

  X: Int64

):Int64;

Description

Swap swaps the high and low order bytes of X if X is of type Word or Integer, or swaps the high and low order words of X if X is of type Longint or Cardinal. The return type is the type of X

Errors

None.

See also

Lo

  

Return low byte/word of value.

Hi

  

Return high byte/word of value.

Example

Program Example69;

{ Program to demonstrate the Swap function. }
Var W : Word;
    L : Longint;

begin
  W:=$1234;
  W:=Swap(W);
  if W<>$3412 then
    writeln ('Error when swapping word !');
  L:=$12345678;
  L:=Swap(L);
  if L<>$56781234 then
    writeln ('Error when swapping Longint !');
end.

Notes

 No notes exist for this page yet. 





lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505