To explain my motivation more clearly in words here:  I'm writing an
XEDIT macro and I want it to act on a range of lines between the current
line and a target just like native XEDIT subcommands.  I want to do my
work in the pipeline, line by line as it reads the file from XEDIT, and
write output into the file, select lines, etc.

On 2019-06-10 3:34 PM, I wrote:
>   'COMMAND EXTRACT /LINE/NBSCOPE'
>   lines = nbscope.2
>   'COMMAND LOCATE' target
>   'COMMAND EXTRACT /NBSCOPE'
>   lines = nbscope.2 - lines
>   'COMMAND LOCATE :' line.1
>   Address COMMAND 'PIPE xedit | take' lines etc.

Computing the number of lines in advance like this worked fine for what
I needed, because I wasn't going to touch any lines in advance.  I was
hiding lines that weren't found in another file:

Address COMMAND 'PIPE (end /) xedit' , /* read from XEDIT */
  '| take' lines                     , /* number of lines requested */
  '| found: lookup'                  , /* match log below */
  '/ disk' fn ft fm                  ,  /* read log from disk */
  '| found:'                         ,  /* nonmatches above */
  '| spec "-1 SET SELECT 1" 1'       ,  /* go back and select */
  '| subcom xedit'                   ,  /* issue subcommands */

But now suppose I wanted to hide that line AND the next two:

Address COMMAND 'PIPE (end /) xedit' , /* read from XEDIT */
  '| take' lines                     , /* number of lines requested */
  '| found: lookup'                  , /* match log below */
  '/ disk' fn ft fm                  ,  /* read log from disk */
  '| found:'                         ,  /* nonmatches above */
  '| spec "-1 SET SELECT 1 3" 1'     ,  /*>go back and select 3 lines<*/

  '| subcom xedit'                   ,  /* issue subcommands */

Now the precomputed count is no good anymore, because those next two
lines will never be read into the pipeline.  That's what I'm wishing for
a way to handle.

¬R

(Warning:  These examples presume SET DISPLAY 0 0 and SET SCOPE DISPLAY.
 Don't try them with SCOPE ALL or with 1 in the DISPLAY range!  You'll
wind up processing the same line forever.)

Reply via email to