home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / pascal / 5164 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  1.3 KB

  1. Path: sparky!uunet!bonnie.concordia.ca!IRO.UMontreal.CA!iros1!shen
  2. From: shen@nil.IRO.UMontreal.CA (Yu Shen)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Append to a stream and read from the stream?
  5. Message-ID: <SHEN.92Sep2054230@nil.IRO.UMontreal.CA>
  6. Date: 2 Sep 92 10:42:30 GMT
  7. Sender: news@IRO.UMontreal.CA
  8. Organization: Universite de Montreal -- Laboratoire Incognito
  9. Lines: 40
  10.  
  11. I would like to use a stream as a buffer, that in a loop, I will
  12. append an object to it, and then read back all the objects written. 
  13. I'm not sure the following sketch is correct:
  14.  
  15. program Sketch;
  16. var
  17. AStream: PDosStream;
  18. AObject: PObject;
  19. BObject: PObject;
  20.  
  21. begin
  22.     AStream := new(PDosStream, init('AStream.Dat', stOpen, 1024));
  23.         {Assume, AStream.Dat file exists, empty}
  24.         {use stOpen, as I need to write and read, right?}
  25.     for i := 0 to 100 do
  26.     begin
  27.         AOject := new(PObject, init);
  28.         ...
  29.         AStrema^.Put(AOject);
  30.         repeat 
  31.         begin
  32.             AStream^.Get(BOject);
  33.             ...
  34.         end;
  35.         until (AStream^.There_is_no_more)
  36.             {There_is_no_more is to be defined. I don't
  37. know how to do it yet}
  38.     end;
  39.     Dispose(AStream, Done);
  40. end;
  41.  
  42. Any suggestion is very much appreciated. Thank you in advance,
  43.  
  44. --
  45. Yu Shen
  46. Dept. d'Informatique et Recherche Operationnelle
  47. University de Montreal, C.P. 6128 Succ. A.
  48. Montreal, Que. Canada, H3C 3J7
  49.  
  50. (514) 342-7089 (H) shen@IRO.UMontreal.Ca
  51.