Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!takemy.news.telefonica.de!telefonica.de!feed.xsnews.nl!border-3.ams.xsnews.nl!feeder.xennanews.com!nf39.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 02:19:42 +0100 Message-ID: <87r4n8nd8x.fsf@Compaq.site.inet> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:U9JSdH1cC/rDmHEebw1qddZBTYI= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@xennanews.com Lines: 25 NNTP-Posting-Host: 84.53.123.169 (84.53.123.169) NNTP-Posting-Date: Mon, 03 Dec 2012 02:29:30 +0100 Xref: csiph.com comp.lang.postscript:1132 Op zondag 2 dec 2012 22:31 CET schreef luser droog: > Chris's response is totally correct. But here's another way to do it. > You can slurp the whole file into one string (assuming the file size is less > than 65535 bytes), and then use `search` to chop it up. > > %! > %farr.ps File into Array > /infile (farr.ps)(r)file def > infile dup bytesavailable string readstring pop > (\n){ search { 3 1 roll }{ exit } ifelse }loop > count array astore == > > gs output: > > [(%!) (%farr.ps File into Array) (/infile \(farr.ps\)\(r\)file def) (infile > dup bytesavailable string readstring pop) (\(\\n\){ search { 3 1 roll }{ > exit } ifelse }loop) (count array astore ==) ()] I already implemented Chris's way, but I'll look into this one also. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof