Re: [Lazarus] reading a little endian long.

2008-12-22 Thread Marc Weustink
Mattias Gaertner wrote: On Mon, 22 Dec 2008 01:11:38 +0100 Marc Weustink m...@dommelstein.net wrote: Dave Coventry wrote: Wow. If I can push a little more: Can I read in an eight-byte IEEE double using the same trick? The example below is not complete, you need to cast.

Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Dave Coventry
Is there any documentation on this? would the following: longv:=LEtoN(@buffer[5]); be the same as: longv:=buffer[5]; longv+=buffer[6] shl 8; longv+=buffer[7] shl 16; longv+=buffer[8] shl 24; 2008/12/21 Andrew Haines andrewd...@aol.com: Yes. See LEtoN, BEtoN, NtoLE and NtoBE. BlockRead(F,

Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Mattias Gaertner
On Sun, 21 Dec 2008 10:26:41 +0200 Dave Coventry dgcoven...@gmail.com wrote: Is there any documentation on this? would the following: longv:=LEtoN(@buffer[5]); longv:=LEtoN(PLongint(@buffer[5])^); be the same as: longv:=buffer[5]; longv+=buffer[6] shl 8; longv+=buffer[7] shl 16;

Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Dave Coventry
Hi Mattias, Is there an equivalent for shortv:=buffer[5]; shortv+=buffer[6] shl 8; Many thanks Dave 2008/12/21 Mattias Gaertner nc-gaert...@netcologne.de: On Sun, 21 Dec 2008 10:26:41 +0200 Dave Coventry dgcoven...@gmail.com wrote: Is there any documentation on this? would the following:

Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Mattias Gaertner
On Sun, 21 Dec 2008 12:04:37 +0200 Dave Coventry dgcoven...@gmail.com wrote: Hi Mattias, Is there an equivalent for shortv:=buffer[5]; shortv+=buffer[6] shl 8; shortv:=LEtoN(PSmallInt(@buffer[5])^); Mattias longv:=LEtoN(PLongint(@buffer[5])^); be the same as:

Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Felipe Monteiro de Carvalho
On Sun, Dec 21, 2008 at 6:26 AM, Dave Coventry dgcoven...@gmail.com wrote: Is there any documentation on this? http://www.freepascal.org/docs-html/rtl/system/index-5.html would the following: longv:=LEtoN(@buffer[5]); be the same as: No, it's better. It only performs a conversion from

Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Dave Coventry
Wow. If I can push a little more: Can I read in an eight-byte IEEE double using the same trick? 2008/12/21 Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com: On Sun, Dec 21, 2008 at 6:26 AM, Dave Coventry dgcoven...@gmail.com wrote: Is there any documentation on this?

Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Marc Weustink
Dave Coventry wrote: Wow. If I can push a little more: Can I read in an eight-byte IEEE double using the same trick? The example below is not complete, you need to cast. MyDouble:=LEtoN(PDouble(@buffer[5])^); Use codejumping (find declaration) on LEtoN to see what variants exist. Marc

Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Mattias Gaertner
On Mon, 22 Dec 2008 01:11:38 +0100 Marc Weustink m...@dommelstein.net wrote: Dave Coventry wrote: Wow. If I can push a little more: Can I read in an eight-byte IEEE double using the same trick? The example below is not complete, you need to cast.

Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Dave Coventry
2008/12/22 Marc Weustink m...@dommelstein.net: The example below is not complete, you need to cast. MyDouble:=LEtoN(PDouble(@buffer[5])^); Use codejumping (find declaration) on LEtoN to see what variants exist. Marc Thanks Marc, I hadn't thought of doing that... Thanks to all the guys

Re: [Lazarus] reading a little endian long.

2008-12-20 Thread Andrew Haines
Dave Coventry wrote: If I Blockread(F,buffer,4) with buffer being an array of byte, Is there a routine in fpc/lazarus which will revers the bytes for me? This is what I want: longv:=buffer[0]; longv+=buffer[1] shl 8; longv+=buffer[2] shl 16; longv+=buffer[3] shl 24; Is there a function

Re: [Lazarus] reading a little endian long.

2008-12-20 Thread Dave Coventry
Great, thanks Andrew. 2008/12/21 Andrew Haines andrewd...@aol.com: Dave Coventry wrote: If I Blockread(F,buffer,4) with buffer being an array of byte, Is there a routine in fpc/lazarus which will revers the bytes for me? This is what I want: longv:=buffer[0]; longv+=buffer[1] shl 8;