home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / ada / 2545 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  2.4 KB

  1. Path: sparky!uunet!haven.umd.edu!mimsy!alex
  2. From: alex@cs.umd.edu (Alex Blakemore)
  3. Newsgroups: comp.lang.ada
  4. Subject: Re: Detecting EOL with SEQUENTIAL_IO!!!!!!!
  5. Message-ID: <60123@mimsy.umd.edu>
  6. Date: 6 Sep 92 03:57:39 GMT
  7. References: <1992Sep5.160811.1@vmsclst1.sc.csupomona.edu>
  8. Sender: news@mimsy.umd.edu
  9. Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
  10. Lines: 42
  11.  
  12. In article <1992Sep5.160811.1@vmsclst1.sc.csupomona.edu> mgeorgy@vmsclst1.sc.csupomona.edu writes:
  13. > Hello, I have noticed that the package SEQUNTIAL_IO does not have
  14. > END_OF_LINE(filename) like TEXT_IO.  Is there a way to get around this (ie
  15. > writing my own, or does one already exist???).
  16.  
  17. Sequential_io manages files that are logically a sequential stream of
  18. objects of type X, where X may be (almost) any single data type of
  19. your choice.
  20.  
  21. The concept of end_of_line (or even just line) just doesn't make sense
  22. with sequential io.  You can read one object of type X after another.
  23. c'est tout.
  24.  
  25. Direct_io is similar but provides (surprise) direct access.
  26.  
  27. Text_io is a very different beast with an idea of a lines of
  28. characters and pages of lines.  Text_io usually writes and reads the
  29. natural text file on the system, which in Unix for example is a stream
  30. of characters some of which may be line feed characters.  In such an
  31. environment, text_io is not very different in practice from
  32. sequential_io instantiated with type character.  I assume this is what
  33. you are doing.  VMS represents text files differently by the way.
  34.  
  35. The fact that you are viewing your file as lines of text suggests that
  36. you may be using the wrong IO package for your application.  Text_IO
  37. may be more appropriate - in which case end_of_line is provided.  You
  38. can still read the file character by character using get if you
  39. prefer.  It may be easier to port to other systems if you don't embed
  40. the knowledge of how lines are separated in text files inside your
  41. program.
  42.  
  43. Or perhaps you should use sequential io on your data type and forget
  44. about lines and characters altogether.  This can be very convenient.
  45. But then there is no reason to expect that you can read and write
  46. such files except via your programs.  Don't expect them to make any
  47. sense in a text editor.
  48.  
  49. If you must do this.  On a Unix system, you can detect a new line in a
  50. text file by comparing the last character read with ascii.lf.
  51. -- 
  52. ---------------------------------------------------
  53. Alex Blakemore alex@cs.umd.edu   NeXT mail accepted
  54.