From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d8a4797a79f9c90f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-27 06:53:55 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!uio.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Re: I/O - exception handling Date: Tue, 27 May 2003 13:53:55 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: References: <3ED2F8A3.6070806@attbi.com> NNTP-Posting-Host: kiuk0152.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1054043635 3082 129.241.83.78 (27 May 2003 13:53:55 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Tue, 27 May 2003 13:53:55 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:37836 Date: 2003-05-27T13:53:55+00:00 List-Id: Robert I. Eachus wrote: > Preben Randhol wrote: >> >> OK understand. *I* would then do: >> >> procedure Safe_Close (File : File_Type)... >> >> Now you can use the Safe_Close in any function you like. > > I have "decorated" open and close routines that I keep copying around > and using in even simple utilities because even the most minimal code to > open a file, check that the open succeeded, or print a diagnotic if it > didn't runs to over a page. But I haven't considered these things as a > good candidate for standardization because there are just too many > different text strings--and personal preferences--involved. > > The other problem is that the open routine can't exit from the enclosing > procedure, so after printing a diagnostic, it has to reraise the > exception (or raise some other exception). This is fine if the program > can't run without an input file, but there are other cases where you > might want to continue. Gets complicated, but that is the nature of a > file that may or may not exist, and may not be accessable due to > permissions, or may be open by some other program for writing and so on. > > The only conclusion I have reached is that there is no such thing as > "simply" opening a file. I agree with that. I also have made a function called: Get_Whole_Line which I use sometimes. What it does it that if a line is longer than the buffer you try to read it into it skips the rest of the line. hello mister handshake godbye If I only want to read the first 5 characters of each line I simply use my Get_Whole_Line procedure with a String (1 .. 5), but I don't think it should be standardized as it is more a special case. Though handy sometimes. -- Preben Randhol http://www.pvv.org/~randhol/