Sounds like you just want the Move procedure. eg:
var
MyArray : Array[1..8] of Byte;
MyLongword : Longword;
begin
{ copy it to the array }
MyLongword := 12345678;
Move(MyLongword, MyArray[1], 8);
{ and back }
Move(MyArray[1], MyLongword, 8);
{ MyLongword should now be 12345678 }
end;
Phil.
----- Original Message -----
From: "Donovan J. Edye" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Friday, July 18, 2003 12:55 PM
Subject: [DUG]: [Q] Sequence of bytes as a number and back again....
> G'Day,
>
> I need to take any number and encode it as a sequence of bytes, and then
> given a known sequence of bytes convert it into a number once more. So
> basically
>
> Anumber : longword --> AbyteArray : array of byte
> AbyteArray : array of byte --> Anumber : longword
>
> This is simple I am sure..... ;-)
>
> Any code snippets greatly appreciated.
>
> TIA
>
> -- Donovan J. Edye
> ----------------------------------------------------------------------
> Namadgi Systems
> Voice: +61-2-6285-3460
> Fax: +61-2-6285-3459
> ----------------------------------------------------------------------
> SetiStats - Get your SETI statistics delivered to your mailbox daily.
> http://www.edye.wattle.id.au/p.php?page=/delphi/setistats
> <http://www.edye.wattle.id.au/p.php?page=/delphi/setistats>
> ----------------------------------------------------------------------
>
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/