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-Thread: 103376,a3fe2aac201210c0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: reading a text file into a string Date: Thu, 15 Jul 2004 20:18:33 +0100 Message-ID: References: <40f6bf21@dnews.tpgi.com.au> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de TEHtxPCc47Hefeye27yNBgO+ZLbI+KtvWGXNwuJ2pJDkMrSv8= User-Agent: Opera M2/7.51 (Win32, build 3798) Xref: g2news1.google.com comp.lang.ada:2191 Date: 2004-07-15T20:18:33+01:00 List-Id: On Thu, 15 Jul 2004 18:59:06 +0100, Marius Amado Alves wrote: > "...is there a more prefered method of reading in a whole text file?" > > The preference depends. That's true, there are many ways to skin a cat, and how you read and process the file will very much depend on what you are trying to do. > The methods are: > > - declare a string S of size equal to the file size and > then call a standard string reading procedure with S as > the out parameter The problem with this idea is that there is no standard way to determine the size of a text file. For some kinds of text 'file' (such as a device or pipe), it may not be possible to tell in advance by any means. > - use stream attributes 'Read, 'Input of type String and > facilities in Ada.Streams.Stream_IO I think this is a terrible idea, unless you know what the character encoding is, and wish to do the decoding yourself! -- Nick Roberts