home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!bonnie.concordia.ca!IRO.UMontreal.CA!iros1!shen
- From: shen@nil.IRO.UMontreal.CA (Yu Shen)
- Newsgroups: comp.lang.pascal
- Subject: Append to a stream and read from the stream?
- Message-ID: <SHEN.92Sep2054230@nil.IRO.UMontreal.CA>
- Date: 2 Sep 92 10:42:30 GMT
- Sender: news@IRO.UMontreal.CA
- Organization: Universite de Montreal -- Laboratoire Incognito
- Lines: 40
-
- I would like to use a stream as a buffer, that in a loop, I will
- append an object to it, and then read back all the objects written.
- I'm not sure the following sketch is correct:
-
- program Sketch;
- var
- AStream: PDosStream;
- AObject: PObject;
- BObject: PObject;
-
- begin
- AStream := new(PDosStream, init('AStream.Dat', stOpen, 1024));
- {Assume, AStream.Dat file exists, empty}
- {use stOpen, as I need to write and read, right?}
- for i := 0 to 100 do
- begin
- AOject := new(PObject, init);
- ...
- AStrema^.Put(AOject);
- repeat
- begin
- AStream^.Get(BOject);
- ...
- end;
- until (AStream^.There_is_no_more)
- {There_is_no_more is to be defined. I don't
- know how to do it yet}
- end;
- Dispose(AStream, Done);
- end;
-
- Any suggestion is very much appreciated. Thank you in advance,
-
- --
- Yu Shen
- Dept. d'Informatique et Recherche Operationnelle
- University de Montreal, C.P. 6128 Succ. A.
- Montreal, Que. Canada, H3C 3J7
-
- (514) 342-7089 (H) shen@IRO.UMontreal.Ca
-