Path: csiph.com!usenet.pasdenom.info!aioe.org!rt.uk.eu.org!feed.xsnews.nl!border-1.ams.xsnews.nl!feeder.xennanews.com!feeder.xennanews.com!nf38.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> X-Homepage: http://www.decebal.nl/ Date: Mon, 03 Dec 2012 00:52:42 +0100 Message-ID: <871uf8ovud.fsf@Compaq.site.inet> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:T4pCE6B1MS2FubzKeOuAH8ICx+I= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@xennanews.com Lines: 32 NNTP-Posting-Host: 84.53.123.169 (84.53.123.169) NNTP-Posting-Date: Mon, 03 Dec 2012 00:59:30 +0100 Xref: csiph.com comp.lang.postscript:1130 Op zondag 2 dec 2012 21:47 CET schreef Chris: > The values get overwritten because you only allocate one string for the > lines to be read into ("/buffer 80 string def"), then reuse it for each > iteration through the loop. > > Something like: > > /inputFile INPUT (r) file def > /linearray > [ > { > inputFile 80 string readline > not > { > pop inputFile closefile > currentdict /inputFile undef > exit > } if > } loop > ] > def > > > will give you the lines of the file in an array called "linearray". Works like a charm. Thanks. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof