[Lazarus] Unpack of PHP
Marco van de Voort
marcov at stack.nl
Wed Feb 6 15:25:48 CET 2013
On Mon, Feb 04, 2013 at 03:29:54PM -0200, silvioprog wrote:
> Oops... And this is the full code:
>
> program project1;
>
> {$mode objfpc}{$H+}
>
> uses
> Classes,
> SysUtils;
>
> function ReadInt(AStream: TStream): Word;
> begin
> Result := 0;
> AStream.Read(Result, SizeOf(Word));
> Result := BEtoN(Result);
> end;
>
> var
> VFile: TFileStream;
> begin
> VFile := TFileStream.Create('data.ascii', fmOpenRead or fmShareDenyWrite);
> try
> VFile.Seek(2, 0);
> WriteLn(ReadInt(VFile));
> VFile.Seek(6, 0);
> WriteLn(ReadInt(VFile));
> finally
> VFile.Free;
> end;
> end.
That's so boring! In FPC 2.7.1 this should work:
uses
Classes,
SysUtils,
StreamEx;
var
VFile: TFileStream;
begin
VFile := TFileStream.Create('data.ascii', fmOpenRead or
fmShareDenyWrite);
try
VFile.Seek(2, 0);
WriteLn(VFile.ReadWordBE);
VFile.Seek(6, 0);
WriteLn(VFile.ReadWordBE);
finally
VFile.Free;
end;
end.
More information about the Lazarus
mailing list