Board index » delphi » Converting Pascal typed files to Delphi 2

Converting Pascal typed files to Delphi 2

I have several large typed files that I need to convert to a Paradox 7.0
table that were created using Turbo Pascal.  The file is defined as follows
in TP:

type FileRec = record
                Part : integer;
                Number : string[14];
                Price : real;
                Pop : char;
                  end;

To import this into Delphi I have defined a record as

type FileRec = record
                Part : smallint;
                        Number : string[14];
                        Price : real;
                        Pop : ANSIchar;
                      end;

But this doesn't import the data correctly.  The Part and Number fields are
read correctly, but the Price always comes out as 0 and the Pop is
incorrect.  What do I need to do to be able to read this file into Delphi.
Any help is much appreciated.

Thanks in advance,
Bret Rumsey

 

Re:Converting Pascal typed files to Delphi 2


In article <01bc3d7f$2b8971a0$0f15a...@primenet.primenet.com>,
  "Bret Rumsey" <rums...@primenet.com> wrote:

Quote

> I have several large typed files that I need to convert to a Paradox 7.0
> table that were created using Turbo Pascal.  The file is defined as follows
> in TP:

> type FileRec = record
>            Part : integer;
>            Number : string[14];
>            Price : real;
>            Pop : char;
>              end;

> To import this into Delphi I have defined a record as

> type FileRec = record
>            Part : smallint;
>                    Number : string[14];
>                    Price : real;
>                    Pop : ANSIchar;
>                       end;

> But this doesn't import the data correctly.  The Part and Number fields are
> read correctly, but the Price always comes out as 0 and the Pop is
> incorrect.  What do I need to do to be able to read this file into Delphi.
> Any help is much appreciated.

      Try "packed record" in place of "record".

      (You should also use single or double instead of real, but
it's probably too late for that here...)

David Ullrich

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

Re:Converting Pascal typed files to Delphi 2


I don't know Turbo Pascal, but you might change the Real type (6 bytes) to Single (4
bytes) or Double (8 bytes).
--
                                                            Cleon.

Bret Rumsey <rums...@primenet.com> wrote in article
<01bc3d7f$2b8971a0$0f15a...@primenet.primenet.com>...

Quote
> I have several large typed files that I need to convert to a Paradox 7.0
> table that were created using Turbo Pascal.  The file is defined as follows
> in TP:

> type FileRec = record
>            Part : integer;
>            Number : string[14];
>            Price : real;
>            Pop : char;
>              end;

> To import this into Delphi I have defined a record as

> type FileRec = record
>            Part : smallint;
>                    Number : string[14];
>                    Price : real;
>                    Pop : ANSIchar;
>                       end;

> But this doesn't import the data correctly.  The Part and Number fields are
> read correctly, but the Price always comes out as 0 and the Pop is
> incorrect.  What do I need to do to be able to read this file into Delphi.
> Any help is much appreciated.

> Thanks in advance,
> Bret Rumsey

Other Threads