Hi,

i need some help about using swap() functions

i am using this code:

var
x: integer;
begin
x := $11223344;
x := swap(x);
edit1.text := inttohex(x);
end;

this code is working fin its swap like this: '22114433' but if i pud/add byte on like this:

var
x: integer;
begin
x := $1122334455667788;
x := swap(x);
edit1.text := inttohex(x);
end;

it does not not, even i use the var longint. any idea what should i do? my expected result is: '2211443366558877'

Thanks

BR,

The swap function is provided for backwards compatibility only. It cannot handle integer/cardinal sized types. It can only handle smallint/word (16-bit) values.

You might want to write your own versions of swap.

try the following

Function Swap(x: integer;y: integer): integer;
var
Temp: integer;

begin
//start swapping;
temp:= edit.text;
edit1.text:= edit2.txt;
edit2.text:= Temp;// you done


end;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.