home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / pascal / 4511 < prev    next >
Encoding:
Text File  |  1992-07-22  |  1.5 KB  |  37 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!cs.utexas.edu!torn!watserv1!watdragon.waterloo.edu!watstat.waterloo.edu!dmurdoch
  3. From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch)
  4. Subject: Re: Variable record files
  5. Message-ID: <Brsx24.HEx@watdragon.waterloo.edu>
  6. Sender: news@watdragon.waterloo.edu (USENET News System)
  7. Reply-To: dmurdoch@mast.queensu.ca
  8. Organization: Queen's University
  9. References: <1992Jul22.131206.51534@ns1.cc.lehigh.edu>
  10. Date: Wed, 22 Jul 1992 17:39:39 GMT
  11. Lines: 24
  12.  
  13. In article <1992Jul22.131206.51534@ns1.cc.lehigh.edu> bsc0@ns1.cc.lehigh.edu (BRIAN STUART COSTELLO) writes:
  14. >If anyone knows of any routines that would allow variable record sizes in a
  15. >file, please tell me.
  16. >
  17. >What's I'd like is the ability to enter in text of any size (up to, say, 20k),
  18. >and when I wrote it to disk, I don't want the record to take up 20k if I
  19. >entered in 1k's worth.
  20.  
  21. Use streams.  You can either put the data in an object, and use the
  22. Put and Get methods from TStream, or just Read and Write it if you don't
  23. want to bother with objects.  
  24.  
  25. A poor alternative, which you'll be stuck with if you're not using TP 6+
  26. (5.5+, actually, if you trust demo code), is to use BlockRead and BlockWrite.
  27. Streams are better:  they're at least as fast, less error-prone, and
  28. much more flexible.
  29.  
  30. The biggest disadvantage to using streams is the documentation:  Chapter 8
  31. of the Turbo Vision guide misleads you into thinking that streams are only
  32. good for objects.  In fact, they're good, general purpose random access
  33. binary files.
  34.  
  35. Duncan Murdoch
  36. dmurdoch@mast.queensu.ca
  37.