[fpc-pascal] TReader.ReadProperty

Michael Van Canneyt michael at freepascal.org
Wed Nov 3 09:17:11 CET 2010



On Wed, 3 Nov 2010, Fred Flinestone wrote:

> hi all,
>
> i am trying to replace the code from delphi to fpc where the code looks
> like:
>
> TYPE THackReader =class(TReader);
>
> ...
>
>    FReaderStream.Position := 0;
>    {$IFDEF FPC}
>    try
>      FReader.ReadListBegin;
>      while not FReader.EndOfList do begin
>        THackReader(FReader).ReadProperty(Obj1);
>      end;
>      Freader.ReadListEnd;
>    except
>    end;
>
>    {$ELSE}
>    FReader.Position := 0;
>    try
>      while FReader.Position < FReaderStream.Size do
>        THackReader(FReader).ReadProperty(Obj1);
>    except
>    end;
>    {$ENDIF}
>
>
> but my code in FPC raises an exception in ReadListBegin method and I am not
> sure if it is correct way to read back properties to Obj1.

No, it is not. However, based on the sample code, it's not possible to give
detailed advice. The above is already a Delphi hack - you can't expect it to 
work as-is in FPC.

In general, I would expect you to use DefineProperties.

>
> PS: How can I debug TReader class, because debuger steps over my calls from
> TReader.

You must recompile the RTL with debug information, and then recompile your
project.

Michael.



More information about the fpc-pascal mailing list