[Lazarus] reading a little endian long.

Andrew Haines andrewd207 at aol.com
Sun Dec 21 03:30:54 CET 2008


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 which does this for me?
> _______________________________________________
>   
Yes. See LEtoN, BEtoN, NtoLE and NtoBE.

BlockRead(F, FooLongInt, 4);

FooLongInt := LEtoN(FooLongInt);

Regards,

Andrew



More information about the Lazarus mailing list