1

I currently have another program that saves a small set of information to a .dat file in the form of a record. I'm currently in the progress of creating another program that looks at this file and displays it within a list box - however, I cannot seem to understand how to read from a file of type (record). Below is what my type declaration looks like:

type orderrec = record
                ordernumber:integer;
                tablenumber:string[10];
                printed:boolean;
                completed:boolean;
end;

I have seen many examples on how to read from a txt file,

lst_tablenumber.items.add('../FrontHouse\ORDERS.DAT');

which is a simple one line of code, however when using it with a record, it just displays a blank field for me.

My current attempts look like this, however I seem to get errors everywhere.

procedure Tfrm_backhome.FormCreate(Sender: TObject);
begin
 reset(orderrec);
  while not eof(orderrec) do
  begin
    read(orderrec,orders);
    lst_tablenumber.items.add(orders.tablenumber);
  end;
  closefile(orderrec);
end;

begin
  assignfile(orderrec,'ORDERS.dat');
  if not fileexists('ORDERS.dat') then
  begin
    rewrite(orderrec);
    closefile(orderrec);
  end;
end;

Thanks for any help.

Adam
  • 11
  • 1

0 Answers0