program PointerRecordExample2( output ); type rptr = ^recdata; recdata = record number : integer; code : string; nextrecord : rptr end; var startrecord, listrecord : rptr; y : char; begin new( listrecord ); if listrecord = nil then begin writeln('1: unable to allocate storage space'); exit end; startrecord := listrecord; listrecord^.number := 10; listrecord^.code := 'This is the first record'; new( listrecord^.nextrecord ); if listrecord^.nextrecord = nil then begin writeln('2: unable to allocate storage space'); exit end; listrecord := listrecord^.nextrecord; listrecord^.number := 20; listrecord^.code := 'This is the second record'; new( listrecord^.nextrecord ); if listrecord^.nextrecord = nil then begin writeln('3: unable to allocate storage space'); exit end; listrecord := listrecord^.nextrecord; listrecord^.number := 30; listrecord^.code := 'This is the third record'; listrecord^.nextrecord := nil; while startrecord <> nil do begin listrecord := startrecord; writeln( startrecord^.number ); writeln( startrecord^.code ); startrecord := startrecord^.nextrecord; dispose( listrecord ) end; readln; end.