home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / w3_prog / stream11.arj / OVRDEMO.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-03-31  |  1.4 KB  |  68 lines

  1. program ovrdemo;
  2.  
  3. { Program to demonstrate use of two overlay files. }
  4.  
  5. uses
  6.   overlay,objects,streams,
  7.   ovr1,ovr2;
  8.  
  9. {$O ovr1}
  10. {$O ovr2}
  11.  
  12. type
  13.   PMessageStream = ^TMessageStream;
  14.   TMessageStream = object(TNamedBufStream)
  15.     { This stream prints its name every time anything is read from it. }
  16.  
  17.     procedure read(var buf; size:word); virtual;
  18.   end;
  19.  
  20. procedure TMessageStream.Read;
  21. begin
  22.   writeln('Reading from ',filename^);
  23.   TNamedBufStream.Read(buf,size);
  24. end;
  25.  
  26. var
  27.   stream1, stream2 : PMessageStream;
  28. begin
  29.   ovrinit('ovrdemo.ovr');
  30.  
  31.   writeln('The overlay streams aren''t being used yet.');
  32.  
  33.   proc1;
  34.   proc2;
  35.  
  36.   writeln('Now loading overlays to the two streams.');
  37.  
  38.   ovrclearbuf;    { Make sure no overlay is loaded. }
  39.  
  40.   new(stream1, init('ovrdemo.1',stCreate,2048));
  41.   ovrinitstream(stream1);
  42.  
  43.   proc1;          { This loads proc1 to Stream1, but doesn't trigger a read
  44.                     yet. }
  45.  
  46.   new(stream2, init('ovrdemo.2',stCreate,2048));
  47.   ovrinitstream(stream2);
  48.  
  49.   proc2;          { This loads proc2 to Stream2, but again, no read. }
  50.  
  51.   writeln('Now each unit is on a different stream; let''s call them a few ');
  52.   writeln('times.');
  53.  
  54.   proc1;
  55.   proc2;
  56.   proc1;
  57.   proc2;
  58.  
  59.   writeln('Now the overlay streams will be disposed of.');
  60.  
  61.   OvrDisposeStreams;
  62.  
  63.   writeln('These calls will use the old overlay mechanism.');
  64.   proc1;
  65.   proc2;
  66. end.
  67.  
  68.