Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!feed.xsnews.nl!border-2.ams.xsnews.nl!feeder.xennanews.com!nf40.xennanews.com!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.postscript Subject: Re: Putting lines from a file into an array Organization: Decebal Computing References: <87624kp6hc.fsf@Compaq.site.inet> <2012120313202243338-john@acumentrainingcom> X-Homepage: http://www.decebal.nl/ Date: Tue, 04 Dec 2012 17:17:11 +0100 Message-ID: <87boe9dc6w.fsf@Compaq.site.inet> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:sMStGvM/YWM1biSIw/RP3kRcMlg= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@xennanews.com Lines: 38 NNTP-Posting-Host: 84.53.123.169 (84.53.123.169) NNTP-Posting-Date: Tue, 04 Dec 2012 17:29:28 +0100 Xref: csiph.com comp.lang.postscript:1142 Op dinsdag 4 dec 2012 10:09 CET schreef Chris: > If I were writing it from scratch myself, I would either (assuming we > know we'd always have a positionable file stream, or that we're allowed > to use ReusableStreamDecode) not read in the entire file at all, but just > find and keep the line(s) of interest at a given time. Well, the way I now want to use it (never know about the future) is that it is a small file (below 1 KB) and I want to use all the lines. At the moment all the lines except the last in the same way. But that properly will change. For example beginning a line with {l}, {r} or {c} would mean that the line should be left justified, right justified or centered. > *Or* I would use (sort of) half of your solution, and use a dictionary as > the "permanent" storage for the file contents, with the line numbers > as Agree, no use converting a dictionary to an array, if you can loop over both. ;-) > the keys. In addition, I would have a single, large line buffer which > gets reused for reading from the file, then I would get the actual length > of each line, and copy it to a new, correctly sized string. Thus > minimising redundant memory use. At the moment I leave the code alone. Done enough with it. But I am still interested how you would do that? Just to learn the language. And who knows: when my usage changes, it would maybe become a good idea to implement it. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof