On Thu, Dec 9, 2010 at 11:13 PM, Mike Walter <[email protected]> wrote:
> '| x: if take' , > '| subcom xedit' , | x: > '| xedit' , > '| x:' The x: was missing there. I was abusing the "if" to divert the first record (the command) to the subcom xedit, and the rest to "xedit" - without the "else" you just issue the command and write the output of subcom (the echoed command) into the file. > BTW, thanks for pointing out the newer STRLITERAL 'CONDitional' keyword, > and for such a concise example of "IF" -- learn something new every day. I'm sure Melinda would have had a serious word with me about using "if" that way ;-) While we're sorting, how about this one? | x: if drop 5 | sort | x: > enhanced learning mode: ON > Attempting to shorten the 2nd example even more by merging the: > '| SPECS /:0 DELETE */' , > '| SUBCOM XEDIT' , > into a single: > '| SUBCOM XEDIT :0 DELETE *' > resulted in the command being greeted with message: Excessive options ":0 > DELETE *" You probably changed a bit more. If you left some of the other parts in, there's also a command passed on the primary input to this subcom stage. That might come out of your input? > The syntax in the Author's Edition lists: >>>--SUBCOM--word--+--------+-->< > +-string-+ > 1) What makes that ":0 DELETE *" command string "excessive options"? > Entered from the XEDIT command line as "PIPE SUBCOM XEDIT :0 DELETE *" it > works just fine (implying that some other pipes factor is in play). > 2) Why does FANOUT (default: STOP ALLEOF) end before passing all sort > output records to its primary *and* secondary output streams? > Could the ":0 DELETE *" have been executed (even though there was an > "excessive options" error message), deleting the file from XEDIT storage > before SORT and FANOUT had a chance to process them all? > 3) Even changing 'TAKE FIRST 1' to 'TAKE LAST 1' (attempting to reduce the > in-storage record copies of the file) did not force the ":0 DELETE *" to > wait until the last sorted record had been output by SORT and FANOUT. > enhanced learning mode: OFF Re 3: Your shortcut will make that "del *" get issued at whenever the dispatcher feels like it, possibly before reading the file... Your command does not come from the output anymore, so the timing is not enforced. It's a race condition (aka leaking pipe) > You wrote "If the file were already fairly sorted"... - I can't rely on > that. I'm trying to define a general purpose diskless xedit pipe sort > idiom that I can copy/paste into almost any future code when needed. > Bubble sorts in XEDIT macro aren't very concise, either. Besides, Pipes > lets one sort multiple ways on all kinds of columns and fields. I just thought it would be a neat idea to move the lines to their proper location rather than replace the file. It would be functionally the same, just maybe cheaper in some cases. But I'm not sure in what order to do the move commands without getting my legs in a twist... | Rob
