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