Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Don Lancaster Newsgroups: comp.lang.postscript Subject: Re: Putting lines from a file into an array Date: Wed, 05 Dec 2012 11:58:11 -0700 Lines: 45 Message-ID: References: <87624kp6hc.fsf@Compaq.site.inet> <871uf8ovud.fsf@Compaq.site.inet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net VkR6pV3y/zNMxb/NQSEVnAxCFYF8C8HfBS1QnH5Y3PNcj/l61KqX547mRNsxUUgV7Y Cancel-Lock: sha1:Ag7aShOlkI+V7/8/Mib1wukgGIY= User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: <871uf8ovud.fsf@Compaq.site.inet> Xref: csiph.com comp.lang.postscript:1149 On 12/2/2012 4:52 PM, Cecil Westerhof wrote: > 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. > The need is called "string dereferencing" As in (reusable_string) dup length string cvs ----> (safe_string) More at http://www.tinaja.com/glib/strconv.pdf -- Many thanks, Don Lancaster voice phone: (928)428-4073 Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552 rss: http://www.tinaja.com/whtnu.xml email: don@tinaja.com Please visit my GURU's LAIR web site at http://www.tinaja.com