That example of LOOKUP is fascinating! Going to take a bit to digest.
After Sir Rob's reply, I managed to hammer out something that works. Perhaps an unbeautiful / inefficient solution, but not sure? Data file (SOMEFILE MAP A) : " *VOLUME: AA1A11 Provologne PEAR Muenster PEAR Mozzerella PEAR *VOLUME: BB2B22 Provologne APPLE Muenster APPLE Mozzerella KIWI *VOLUME: CC3C33 Provologne KIWI Muenster KIWI Cheddar PEAR " (Where, for example: "VOLUME: AA1A11" / Word2 is our Volser. And in its proceeding record set: Word2 is the Subpool (Ex: "PEAR").) Output produced: " Setup Complete. Outputting now: Subpool=APPLE BB2B22 Muenster BB2B22 Provologne Subpool=KIWI BB2B22 Mozzerella CC3C33 Muenster CC3C33 Provologne Subpool=PEAR AA1A11 Mozzerella AA1A11 Muenster AA1A11 Provologne CC3C33 Cheddar Ready ; T=0.01/0.01 11:39:31 " Program source copy WITHOUT comments: " /* */ ADDRESS COMMAND 'PIPE (endchar ?) < SOMEFILE MAP A' , '| A: FIND *VOLUME' , '| SPEC W2 1.7' , '| B: JUXTAPOSE' , '| SPEC W3 1.6 W1 NW.6 W2 NW W4-* NW' , '| SORT' , '| C: CHOP 7' , '| STRIP' , '| UNIQUE FIRST' , '| STEM Subpools1.' , '| SPEC W1 1.7' , '| D: JUXTAPOSE COUNT' , '| SPEC ,/, 1 11-16 STRIP N ,., N 1.10 STRIP N ,/, N W2-* N WRITE' , ',/, 1 11-16 STRIP N ,.0/, N 1.10 STRIP N' , '| VARSET' , '?A:| B:' , '?C:| D:' SAY "Setup Complete. Outputting now:" DO i=1 FOR Subpools1.0 SAY "Subpool="Subpools1.i 'PIPE STEM 'Subpools1.i'. | CONSOLE' END EXIT " Program source WITH comments: " /* Test / Example program. */ /* Make a report of Subpools, then organized by Volser. */ ADDRESS COMMAND 'PIPE (endchar ?) < SOMEFILE MAP A' , '| A: FIND *VOLUME' , /* Take only '*VOLUME' records. */ '| SPEC W2 1.7' , /* Keep Volser, fill 7 col. */ '| B: JUXTAPOSE' , /* Prepend Volser to each of its records. */ '| SPEC W3 1.6 W1 NW.6 W2 NW W4-* NW' , /* Subpool in front. */ '| SORT' , /* Sort by Subpool, then Volser. */ '| C: CHOP 7' , /* Let only first 6 char through (Subpool). */ '| STRIP' , /* Cleanup spaces for Subpool recording. */ '| UNIQUE FIRST' , /* Above UNIQUE FIRST does: */ , /* Make sure duplicate Subpool names don't get recorded. */ , /* Make sure JUXTAPOSE COUNT doesn't give all "1". */ , '| STEM Subpools1.' , /* Keep track of the Subpool names. */ '| SPEC W1 1.7' , /* Make sure fills exactly 6+1 columns. */ '| D: JUXTAPOSE COUNT' , /* Count number of entries in each Subpool. */ '| SPEC ,/, 1 11-16 STRIP N ,., N 1.10 STRIP N ,/, N W2-* N WRITE' , ',/, 1 11-16 STRIP N ,.0/, N 1.10 STRIP N' , /* Above SPEC puts records in proper format for VARSET. EX: */ , /* /APPLE.1/BB2B22 Mozzerella */ , /* /APPLE.0/1 */ , '| VARSET' , /* Populate numeric STEMs whose names are the Subpools. */ '?A:| B:' , /* Move Volser-related records. */ '?C:| D:' /* Move Subpool-related records. */ SAY "Setup Complete. Outputting now:" DO i=1 FOR Subpools1.0 SAY "Subpool="Subpools1.i 'PIPE STEM 'Subpools1.i'. | CONSOLE' END EXIT " --Shawn S. -----Original Message----- From: CMSTSO Pipelines Discussion List [mailto:CMS-PIPELINES@VM.MARIST.EDU] On Behalf Of Rob van der Heij Sent: Thursday, September 22, 2016 5:11 PM To: CMS-PIPELINES@VM.MARIST.EDU Subject: Re: [CMS-PIPELINES] Not-always-directly-sequential record references in PIPEs > Perhaps this would involve one of the more complicated usages of SPEC that > Mike alluded to? No, that works with the COUNT option of JUXTAPOSE, but you'd have to set the .0 entry too (I would probably write the .0 entry with each of them, like this: spec ,/, 1 w6 n ,., n 1.10 strip n ,/, n 11-* n write ,/, 1 w6 n ,.0/, n 1.10 strip n If nothing else, LOOKUP can do the trick, and well worth learning. Almost fit on the command line for me, but made it a REXX filter. The output of this would feed into VARSET. 'callpipe (end \ name SS1.REXX:2)', '\ *: ', '| v:find *VOLUME:', '| spec w2 1 w4 10.5', '| j:juxtapose', '| l:lookup autoadd before count trackcount w6 master detail', '| i:fanin', '| spec ,/, 1 w6 n ,., n 1.10 strip n ,/, n read 1-* n', '| *:', '\ v:', '| spec 11.34 1 68.8 nw ', '| j:', '\ l:', '\ l:', '| spec 1-* 1 ,0, 1.10 r write 1.10 strip 1', '| i:' In case it's not immediately obvious, LOOKUP is used to match the records on the pool name. The reference table is initially empty. With AUTOADD BEFORE each new pool is added to the table so further ones can be matched. The TRACKCOUNT numbers the detail records as they match the master (the BEFORE allows also the first one to match itself, so counting starts at 1). Finally, the COUNT option makes the total number of hits per pool come out; they are morphed into the .0 entry. Sir Rob the Plumber