Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!sejnet.sunet.se!eric From: eric@sejnet.sunet.se (Eric Thomas, SUNET) Newsgroups: comp.lang.rexx Subject: Re: REXX, VM/CMS Message-ID: <2848@sunic.sunet.se> Date: 23 Jan 91 18:20:32 GMT References: <1991Jan22.022019.5280@ncsuvx.ncsu.edu> <1991Jan23.135615.20072@lotus.com> Sender: news@sunic.sunet.se Reply-To: eric@sejnet.sunet.se Organization: Swedish University Network (SUNET), Stockholm, Sweden Lines: 40 News-Software: VAX/VMS VNEWS 1.3-5 Well, the original program had a lot of examples of things one should not do, but I didn't want to comment - there's just too many programs like that, and the original poster hadn't said this way the "right way" to do it, just that the program works :-) In article <1991Jan23.135615.20072@lotus.com>, patman@lotus.com (Pat Mancuso) writes... >ACK! Don't do a diskr for each line of the result! That could >take forever! There is a *much* more efficient way to do this: > >'MAKEBUF' >'LISTFILE * * A (STACK FIFO NOH' >line.0 = queued() ^^^^^^^^ >do i = 1 to line.0 > parse pull line.i >end >'DROPBUF' This will read anything that might have been previously stacked by another program (possibly the program that called this one). These are don't contain LISTFILE output, so your program may crash, and the calling program will most probably issue terminal reads or get a REXX error. What you want to do is save 'queued()' into some variable before the LISTFILE, and place the difference between 'queued()' and that variable in line.0; if you don't do that, there's no point in using MAKEBUF to isolate your data from what was previously stacked. >If you really *have* to read in a bunch of lines from a file, >use something like: >'EXECIO * DISKR' fn ft fm '(FINIS STEM LINES.' >(the trailing dot is important, as EXEC2 isn't real bright...) EXEC2? Did you mean EXECIO? It was designed to allow you to write the result into LINE1, LINE2, LINE3... if such is your desire. Consider the case of a file which you know to have only 2 lines, ie where you are not going to do a 'Do i = 1 for line.0'; it makes sense to have the result in LINE1 and LINE2, which REXX can also access more efficiently (whereas each access to a stem variable involves the overhead of evaluating the tail). Eric