A.2 reading ppufiles

We will first create an object ppufile which will be used below. We are opening unit test.ppu as an example.

 var
   ppufile : pppufile;
 begin
 { Initialize object }
   ppufile:=new(pppufile,init('test.ppu');
 { open the unit and read the header, returns false when it fails }
   if not ppufile.openfile then
     error('error opening unit test.ppu');
 
 { here we can read the unit }
 
 { close unit }
   ppufile.closefile;
 { release object }
   dispose(ppufile,done);
 end;

Note: When a function fails (for example not enough bytes left in an entry) it sets the ppufile.error variable.