Rob,
Thank you!
I did not really understand the point of the first bit of code,
adding the * to records seemed unnecessary if I already know the delimiting
string.

I created one driver exec with this:
/*   */
TRACE N
ARG FID
'PIPE (END ?) <' FID '| KT00SUB'

EXIT

and one sipper like this:
/* KT00SUB REXX  */
  SIGNAL ON ERROR
  DO FOREVER
    'PEEKTO'
    'CALLPIPE (END ?) *: |',
         'A: TAKE | ',
         'F: FANINANY | ',
         '> TEMP FILE A ?',
         'A: | STRTOLABEL .KTA. |',
         'F:'
    ADDRESS COMMAND 'EXEC ... '
  END
ERROR: EXIT

It did exactly what I needed. Thank you VERY much for the help. :)
Shimon


On Sun, Nov 25, 2012 at 6:24 PM, Rob van der Heij <[email protected]> wrote:

> On 25 November 2012 17:08, Shimon Lebowitz <[email protected]> wrote:
> > Hi,
> > I am not sure how to define this problem, but it sure LOOKS like
> something
> > I should be able to do in pipes.
> >
> > Given: a data file, starting with a 'delimiter line', and with more of
> them
> > distributed (in no known
> > placement) throughout the data (but NOT as a final delimiter at the end
> of
> > the file).
>
> Are you serious that the delimited line is specified in the data, and
> not in the code? If so, then what I do is (obviously) use "lookup" to
> find the markers in the stream. The following to prefix the delimiter
> with a * and the others with a blank
>
>   \ *:
>   | d: drop
>   | z: lookup detail  | insert / /
>   | i: faninany ...
>   \ d: | insert /*/ | z:
>
> If you know how to recognize the delimiters already, then use that in
> the snippet below...
>
> > Requirement: read the file, up to, but NOT including the second delimiter
> > line (remember, the very first
> > line of the file is also one), store those lines in a temporary file, and
> > invoke an exec against that file.
> > Then continue reading from the 2nd delimiter line, up to but not
> including
> > the third one, store, run
> > exec, etc. until EOF.
>
> The easy way is a "sipping pipeline" like this:
>   signal on error
>   do forever
>     'peekto'
>     'callpipe (end \) *: | drop | strtolabel /*/ | substr 2-* | > temp
> file a'
>     address command 'EXEC ...'
>   end
>
> There's more interesting ways, but this is probably the simplest.
>
> | Rob
>

Reply via email to