On 6/23/2015 7:35 AM, Alain Benveniste wrote: > Based on key cyls I want to match line1 of file1 with the first line > in line 2 that has the same cyls value. When picked up, the line in > file2 can not be reselected.
I'm kind of surprised I never had to tackle this same problem. Sadly, there's no COLLATE PAIRWISE or LOOKUP AUTODELETE. And, actually, even using LOOKUP ALLMASTERS to keep multiple reference records with the same key, when you delete a reference record, all the records matching the key are deleted at once, so you'd have to pick out the first match to delete it, and then add the rest back in. The timing of the feedback gets tricky, and I -did- come up with a neat trick for that a while back: Instead of loosening things up with COPY or ELASTIC, use CHOP and FANINANY to feed a null record to the input of BUFFER 1, to delay the records on the alternate streams by just the right amount. 'PIPE (end /)' etc. , /* primary input here */ '| after: chop not 00-ff' , /* send null below */ '| match: lookup' whatever , /* match up records */ '| wait: faninany' , /* add in null below */ '| buffer 1' , /* delay output until null */ '| locate' , /* skip null */ more processing here , /* feedback, other inputs to match: */ '/ after:' , /* null from above */ '| wait:' , /* add to output above */ After LOOKUP releases its input record, CHOP writes a null record to its alternate, flushing the buffer, and BUFFER writes all the output for that record before CHOP can pass the next input record to LOOKUP. That way, you know LOOKUP has had a chance to handle all the records you feed back before it reads the next input record. ¬R
